php serialize unserialize

by saravana 2014-02-21 15:05:00


string serialize ( mixed value)
mixed unserialize ( string input)
string urlencode ( string text)
string urldecode ( string encoded)


As arrays are complex data types, you cannot see their contents directly.

If you try printing out the value of an array, you will see PHP just outputs 'Array', which means that passing the value of an array through a link requires a lot of work.

Serialize() converts an array, given as its only parameter, into a normal string that you can save in a file, pass in a URL, etc.

Unserialize() is the opposite of serialize() - it takes a serialize()d string and converts it back to an array.


Example


$array["a"] = "Foo";
$array["b"] = "Bar";
$array["c"] = "Baz";
$array["d"] = "Wom";

$str = serialize($array);
$strenc = urlencode($str);
print $str . "
";
print $strenc . "
";
?>
1064
like
0
dislike
0
mail
flag

You must LOGIN to add comments