Array to object
<?php
$arr = array(
"abc" => "abc",
"def" => 123.5,
"ghi" => array(1,2,3),
0 => "def"
);
$key = "abc";
$obj = (object) $arr;
echo "First value = $obj->abc\n";
echo "Second value = $obj->def\n";
echo "Third value = $obj->ghi\n";
?>
Related examples in the same category