php | var export

var_export

Write an array to file

file_put_contents($filename, '<?php $array = ' . var_export($array, true) . ';');

file_put_contents($filename, '<?php ' . var_export($array, true) . ';');

Read back from the file into a variable:

include($filename);

$array = include($filename);

eval('$somevar = ' . $dumpStr);

Reference:

procurios.nl

stackoverflow

stackoverflow