Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: curly braces variable $fin_type_{$z} not working

Tags:

php

I have this:

echo 'm=>'.$fin_type_2; // echoes 'test text';

Now, if I do the following, I get nothing, whereas I was expecting the same result as above. What I am doing wrong here ?

$z=2;
echo 'm=>'.$fin_type_{$z}; // echoes nothing but m=>

Help appreciated. Many thanks.

like image 422
Jeremy Roy Avatar asked Feb 28 '26 05:02

Jeremy Roy


1 Answers

i would use something like this:

${'fin_type_'.$z}

(besides this page of php documentation helped myself sometimes)

like image 119
rokdd Avatar answered Mar 01 '26 18:03

rokdd