Serialize

Serialize

serialize() Returns a string containing a byte-stream representation of any variable.

Is used to store the variables in the same format
without loosing their data type and structure
for example we have an array of varying number of keys
which we want to store and use it in another script
Its very tedious to store it in database and retrieve .
In such case we can serialize it and store the resulting
string and get back the value and unserialize it get
the array as it is in original form

‘hai’,'b’=>’how you’,'three’);
$st = serialize($arr);
$val = unserialize($st);
var_dump($val);
?>

Result is:
array(3) { [”a”]=> string(3) “hai” [”b”]=> string(8) “how are you” [0]=> string(14) “three” }

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.