serialize() function is used to convert complex data types (arrays, objects, etc.) into a string format that can be easily stored in database.

<?php
$data = array(
    "name" => "John",
    "age" => 30,
    "city" => "New York"
);
$result = serialize($data);
echo $result;
?>

Output:

a:3:{s:4:"name";s:4:"John";s:3:"age";i:30;s:4:"city";s:8:"New York";}
 

a=size of array
i=count of array number
s=size of array values