I've outputted my array to file using the print_r($myArray, true)
method, but am having trouble re-importing it as an array.
I keep returning a string with the array, not the array itself. I've tried a few different combinations including print_r and serialize, but can't seem to get it right. What am I missing?
Here's what I have:
$myArray = print_r(file_get_contents($logFile), true);
for reference the log file content looks like so:
Array
(
[0] => Array
(
[0] => blah
[1] => blah
)
...
Thanks
EDIT: Solution - Here is what I came up with:
I changed the file contents to include php tags and declared the array there using var_export instead of print_r.
Here is what I used as my content string when writing to file:
<?php $myArray = '.var_export($myArray, true).'; ?'.'>
From there it was a simple include to get the array back.