Well, there are several methods to make arrays, but to save them it is easiest to use serialize. It retains about every aspect of variable. However if you are doing Object Oriented Programming, it does not retain the functions for a class. You can usually use serialize() to safely store your values in a text format that you can restore at a later time. This tutorial demonstrates what it does, and sort of how PHP uses serialize and unserialize.
Here are the sources used in this tutorial:
another.php
<?php //Another file that will use Tutorial 30's generated data and display something. $sdata = file_get_contents("blah.txt"); $data = unserialize($sdata); foreach($data as $date){ echo "<br />Johnny ate an apple on the day: ".date("D, d M Y H:i:s e", $date); } ?>
blah.txt
a:10:{i:0;i:1257216564;i:1;i:1257216565;i:2;i:1257216566;i:3;i:1257216567;i:4;i:1257216568;i:5;i:1257216569;i:6;i:1257216570;i:7;i:1257216571;i:8;i:1257216572;i:9;i:1257216573;}
tut030.php
<?php //PHP Tutorial 30 To Serialize, or to Unserialize $times = array(); for($x = 0; $x < 10; $x++){ $times[]= time()+$x; } file_put_contents("blah.txt",serialize($times)); ?>