PHP/Class/object

Материал из Web эксперт
Перейти к: навигация, поиск

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";?>