I've the following variable that is dinamically created:
$var = "'a'=>'123', 'b'=>'456'";
I use it to populate an array:
$array=array($var);
I can't do $array=array('a'=>'123', 'b'=>'456') because $var is always different.
So it shows me:
Array
(
[0] => 'a'=>'123', 'b'=>'456'
)
This is wrong, 'cause I need to get:
Array
(
[a] => 123
[b] => 456
)
What is wrong on my code? Thanks in advance.
$varin the first place. Consider generating it as a JSON string -{"a":"123", "b":"456"}as you can then use standard JSON methods to convert it.json_encode()andjson_decode()