Convert variables from arrays to objects and back again : object « Class « PHP






Convert variables from arrays to objects and back again

 
<?php 
$a = array( 
    "Name" => "John", 
    "Address" => "Street", 
    "City" => "New York", 
    "State" => "CA", 
    "Zip" => "11111" 
); 
echo "Name = " . $a["Name"] . "\n"; 
$o = (object)$a; 
echo "Address = $o->Address\n";?>
  
  








Related examples in the same category