using eval in PHP with multidimensional array

h3 (7Or

New Member
I have a array that I am writing to a file using \[code\]var_export()\[/code\]. I reload the array every time the script starts. However, whenever I try to reference a variable inside the array it returns 'a', I can do a \[code\]print_r()\[/code\] and see the array just fine, I just can not access the variable I want. Here is the saved output:\[code\]array ( 'timestamp' => '1283882964', 'files_submitted' => 2943, 'errors' => array ( '/home/benk/bull_copy/bull_mnt//WebFS/Projects/Inactive/2002_Product_Testing/tests/Functional Test Cases 2001122301.doc' => array ( 'STATUS' => 400, ), '/home/benk/bull_copy/bull_mnt//WebFS/Projects/Inactive/2002_Product_Testing/tests/Functional Test Cases for atrust 20020905.doc' => array ( 'STATUS' => 400, ), ))\[/code\]Here is the code I use to save:\[code\]function add_log_entry($filename,$return_arr) { //$timestamp = strval(mktime()); $return_arr['timestamp'] = mktime(); $return_str = var_export($return_arr,true); return file_put_contents($filename, $return_str);}\[/code\]Here is the code I use to recall the array:\[code\]function get_log_entry($filename) { $var_str = file_get_contents($filename); eval("\$return_var = \$var_str;"); die($return_var['timestamp']); return $return_var;}\[/code\]You can see I put the \[code\]die()\[/code\] in the recall code and this is where the 'a' is coming from. Thanks to whom ever responds.Ben
 
Back
Top