Serialize---------to format an array as an ordered string
Unserialize-----to restore arrays
Examples of PHP serialized array tests:
$test = Array ("A" =>0, "B" =>0, "C" =>0);
$test 2 = ";
$test 2=serialize ($test);
echo $test 2;
echo "";
Print_r (Unserialize ($test 2));
PHP Serialization Array uses:
In my personal experience, I mainly deal with array transfer, array repository operation.
For example I have an array that needs to be passed to the next page, if you don't want to use Seesion/cookie, then you can take advantage of that function, pass it, and then restore it.
For example, when I do the directory of the site, there is a score, divided into high praise, evaluation, bad reviews. Then my database gives this feature a field that is designed to be a long character type. Combine three comments into an array of:
Array
' A ' + 0,//rated 0
' B ' + = 0,//rating 0
' C ' + 0//difference rating 0
)
After converting it with the Serialize function: a:3:{s:1: "a"; I:0;s:1: "B"; I:0;s:1: "C"; i:0;}, and then the database exists. Do not forget to use the Unserialize function to convert to an array when you remove it.
This is the correct way to use the PHP serialized array.
http://www.bkjia.com/PHPjc/446013.html www.bkjia.com true http://www.bkjia.com/PHPjc/446013.html techarticle serialize---------to format the array into an ordered string unserialize-----to restore an array of arrays of PHP serialized array Test instances: $test = Array (a=0,b=0,c=0); $test 2 = "; $t ...