I have
$string = "temp";
I want extract string value and make new variable (array) :
$temp = array();
is possible?
Sure you can!
${$string}
then you can call it like this: $temp;
more information: http://php.net/manual/en/language.variables.variable.php
With this method you can use it in a for loop to create a bunch of variables in no time :)
exemple:
${'box_'.$i.'_image};
$temp, why not use it like so from the beginning? You should continue using ${$string} everywhere...You can use Variable variables.
Example:
$string = "temp";
$$string = array();
var_dump($temp);
var_dump($$string);//Same as var_dump($temp)
However I find this can lead to difficult to read code, there is usually other ways to do what you are needing.
You can just use Variable variables:
$string = "temp";
$$string = array();
More information at http://php.net/manual/en/language.variables.variable.php.
$temp[]=$string;then print$tempwithprint_r($temp);You will get result of$temparray with value.$temp[] = $string;will create an array named$tempwith the content of$stringon next position (in this case, probably0). It's not the same as creating a variable where it's name is informed as string in another variable. Take a loot at the result of what you suggested: https://3v4l.org/Mmo5F. Take a look at the expected: https://3v4l.org/U4qWv