JuLy JuLy - 3 months ago 9x
PHP Question

String "array" to real array

Now I got the string of an array, like this :

$str = "array('a'=>1, 'b'=>2)";

How can I convert this string into real array ? Is there any "smart way" to do that, other that use explode() ? Because the "string" array could be very complicated some time.

Thanks !


i don't know a good way to do this (only evil eval() wich realy should be avoided).

but: where do you get that string from? is it something you can affect? if so, using serialize() / unserialize() would be a much better way.