View Single Post
Old 07-15-2009, 01:48 AM   #2 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

It's basically the representation of an array as a string. Good for storing the contents of an array in a file, and then being able to rebuild it with ease.

Take the following as a good example. Here we're saving the array, and then reloading it. It will give us the array just how we had it when we created it initially.

php Code:
function TalkPHP_Array_Save($aMyArray)
{
    $szSerialize = serialize($aMyArray);
    file_put_contents('myArray.txt', $szSerialize);
}

function TalkPHP_Array_Load()
{
    $szSerialize = file_get_contents('myArray.txt');
    return unserialize($szSerialize);
}

$aFruit = array('Orange', 'Apple', 'Banana');

/* Save and unset the array. */
TalkPHP_Array_Save($aFruit);
unset($aFruit);

/* Reload the array from a serialized string. */
$aFruit = TalkPHP_Array_Load();
print_r($aFruit);
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote