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

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.