I discovered the var_export function in PHP about a year ago. It is able to return a string that represents the passed variable. The returned string is parsable by PHP.
One way to use this function would be to cache an array to a file.
In example:
export.php <?php //will write the array to disk $ar = array('test','testing'); $content = var_export($ar,true); file_put_contents('cache.php',"<?php\n\$cache=$content;"); ?> import.php <?php //will output the cached array include 'cache.php'; var_dump( $cache );
An even easier method is writing
return $contentto the file, in this case you can assign the cached data to a var by using$cache = include 'cache.php';and avoid naming collisions