ArrayObject::unserialize


Unserialize an ArrayObject.



<?php

void 
public ArrayObject::unserialize str $serialized )


where,

$serialized A serialized STRING by ArrayObject::serialize

?>

$serialized


A serialized STRING by ArrayObject::serialize.



  1 EXERCISE   

<?php

$Dwarfs 
= [ => 'Bashful'=> 'Doc'
                   
=> 'Grumpy'=> 'Happy'
                   
=> 'Sneezy'=> 'Sleepy'=> 'Dopey'
                   
=> 'Snow White'];

$dwArrayObject = new ArrayObject($Dwarfs);

$str01 serialize($dwArrayObject);

echo 
$str01;

$Dwarfsu unserialize($str01);

echo 
'<br><br>';

var_dump($Dwarfsu);


?>

 RESULT   

SERIALIZED ArrayObject

O:11:"ArrayObject":3:{i:0;i:0;i:1;a:8:{i:1;s:7:"Bashful";i:2;s:3:"Doc";i:3;s:6:"Grumpy";i:4;s:5:"Happy";i:5;s:6:"Sneezy";i:6;s:6:"Sleepy";i:7;s:5:"Dopey";i:8;s:10:"Snow White";}i:2;a:0:{}}

UNSERIALIZED ArrayObject

object(ArrayObject)#2 (1) { ["storage":"ArrayObject":private]=> array(8) { [1]=> string(7) "Bashful" [2]=> string(3) "Doc" [3]=> string(6) "Grumpy" [4]=> string(5) "Happy" [5]=> string(6) "Sneezy" [6]=> string(6) "Sleepy" [7]=> string(5) "Dopey" [8]=> string(10) "Snow White" } }


  2 EXERCISE   

<?php

class Dwarfs
{
const 
MYARRAY = [ => 'Bashful'=> 'Doc'
                   
=> 'Grumpy'=> 'Happy'
                   
=> 'Sneezy'=> 'Sleepy'=> 'Dopey'
                   
=> 'Snow White'];
    
    
public static function 
serialz()
{
    return 
serialize(self::MYARRAY);
}

public static function 
userialz()
{
    return 
unserialize(serialize(self::MYARRAY));
}
}


var_dump(Dwarfs::serialz());
echo 
'<br><br>';
var_dump(Dwarfs::userialz());


?>

 RESULT   

SERIALIZED ArrayObject

O:11:"ArrayObject":3:{i:0;i:0;i:1;a:8:{i:1;s:7:"Bashful";i:2;s:3:"Doc";i:3;s:6:"Grumpy";i:4;s:5:"Happy";i:5;s:6:"Sneezy";i:6;s:6:"Sleepy";i:7;s:5:"Dopey";i:8;s:10:"Snow White";}i:2;a:0:{}}

UNSERIALIZED ArrayObject

object(ArrayObject)#2 (1) { ["storage":"ArrayObject":private]=> array(8) { [1]=> string(7) "Bashful" [2]=> string(3) "Doc" [3]=> string(6) "Grumpy" [4]=> string(5) "Happy" [5]=> string(6) "Sneezy" [6]=> string(6) "Sleepy" [7]=> string(5) "Dopey" [8]=> string(10) "Snow White" } }