PHP:花括号变量$ fin_type _ {$ z}不起作用

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.

i would use something like this:

${'fin_type_'.$z}

(besides this page of php documentation helped myself sometimes)

You should probably use arrays (numeric and associative) to achieve your goal.

I'm afraid that closest you can get is

<?php
$fin_type_2 = 'test text';
$z = 2;
$v = "fin_type_$z";
echo 'm=>'.$v;

However, think twice before applying variable variables like that. Perhaps using array would fit your case better?

<?php
$fin_type = array();
$fin_type[2] = 'test text';

$z = 2;
echo "m=>{$fin_type[$z]}";