View Full Version : how can i save the output of array ?
qwe010
23rd September 2008, 13:01
hello
how can i save the output of array in php?
print_r($array);
any idea ?
topdog
23rd September 2008, 15:16
what do u mean save it, you already have it in the variable, you can use the contents of the variable at anytime with in the lifespan of the script.
Ben
23rd September 2008, 15:44
if you want to store it anywhere, to e.g. rebuild again use serialize / unserialize:
$myarray = array(1,2,3);
var_dump($myarray);
$myarraySerialized = serialize($myarray);
unset($myarray);
var_dump($myarray);
$myarray = unserialize(myarraySerialized);
var_dump($myarray);
If you meant to store an print_r / var_dump equivalent output of the array structure the use var_export(your_var, true). The second parameter is important here.
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.