1$arrayResult = array_map(function($array){
2 return (object)$array;
3}, $yourOrinalArray);
1<?php
2function toObject($arr) {
3 if (is_array($arr)) {
4 // Return object
5 return (object) array_map('toObject', $arr);
6 }
7 return false;
8}
9$empInfo = array(
10 'name'=>'John',
11 'address'=>'Houston',
12 'employment' => array
13 (
14 'id' => '1',
15 'address' => 'Los Angeles'
16 )
17);
18print_r(toObject($empInfo));
19
20/*_____output_______*/
21// OUTPUT
22
23/*stdClass Object
24(
25 [name] => John
26 [address] => Houston
27 [employment] => stdClass Object
28 (
29 [id] => 1
30 [address] => Los Angeles
31 )
32)*/