phparrayssyntaxbracesvariable-variables

What does ${$item} mean?


I'm not able to understand braces goal in the situation below and I find no serious documentation about braces usage.

See the example below:

 $var = array('a','b','c','d');

 foreach($var as $item){

       ${$item} = array();

 }

I'm non understanding ${$item} meaning.

I've tried with var_dump before and after foreach loop but it seems nothing happens.

Any ideas?


Solution

  • It creates 4 empty arrays:

    $a, $b, $c, $d // arrays now