convert array to object in php example
<?php function toObject($arr) { if (is_array($arr)) { // Return object return (object) array_map('toObject', $arr); } return false; } $empInfo = array( 'name'=>'John', 'address'=>'Houston', 'employment' => array ( 'id' => '1', 'address' => 'Los Angeles' ) ); print_r(toObject($empInfo)); /*_____output_______*/ // OUTPUT /*stdClass Object ( [name] => John [address] => Houston [employment] => stdClass Object ( [id] => 1 [address] => Los Angeles ) )*/