Eval string to array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Im trying to evaluate a string representation of the output of var_export(),
as an array.
To make a long story short, Im using curl to fetch another php page,
that uses var_export to echo out php data structures.
The fetched data via curl, is a string. Something like ->
array ( 'foo' => 'bar', )


I would like to convert this to a real array.
Im currently trying this ->
$ret = curl_exec($this->curl_handle);
$str = '$array = $ret;';
eval($str);
var_dump($ret, $array);

The resulting var_dump() shows that my eval'ed data is still a string.
string(27) "array ( 'foo' => 'bar', )" string(27) "array ( 'foo' => 'bar', )"
What should I be doing to get it as an array ->
array(1) { ["foo"]=> string(3) "bar" }


Thanks for your time.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux