Serialize and unserialize array : unserialize « Utility Function « PHP






Serialize and unserialize array

 
<?php

$arr = array("apple", "orange", "pear");
define('MYARRAY', serialize($arr));

function MyTest() {
  print_r(unserialize(MYARRAY));
}

MyTest();
?>
  
  








Related examples in the same category

1.Encapsulating Complex Data Types
2.convert the string produced by serialize() back into an object with the unserialize() function.