Hi,
Suppose the following string variable,
$arg = 'array("r1"=>array("f1"=>1,"f2"=>2,"f3"=>3))';
As you see the string is an array intiation statement.
When I try to cast it to an array using PHP casting as follows,
$arr = (array) $arg;
It returns an array its index number of 0 holds the string as its value, and this is the output
of print_r for it,
Array
(
[0] => array("r1"=>array("f1"=>1,"f2"=>2,"f3"=>3))
)
What I want to do is:
Converting this string as a real array. Supposing removing the quots:
$arr = array("r1"=>array("f1"=>1,"f2"=>2,"f3"=>3));
In other word
I want something($arg) to make print_r(ofThatThing) to print out
Array
(
[r1] => Array
(
[f1] => 1
[f2] => 2
[f3] => 3
)
)
You may ask, Why I want to do that?
I want to do that because I want to generate a dynamic array during the run time, not only
to store variables inside it.
Is this possible?
😕