在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1 function array2object($array) { 2 3 if (is_array($array)) { 4 $obj = new StdClass(); 5 6 foreach ($array as $key => $val){ 7 $obj->$key = $val; 8 } 9 } 10 else { $obj = $array; } 11 12 return $obj; 13 } 14 15 function object2array($object) { 16 if (is_object($object)) { 17 foreach ($object as $key => $value) { 18 $array[$key] = $value; 19 } 20 } 21 else { 22 $array = $object; 23 } 24 return $array; 25 } 1 $array = array('foo' => 'bar', 'one' => 'two', 'three' => 'four'); 2 3 $obj = array2object($array); 4 print $obj->one; // output's "two" 5 6 $arr = object2array($obj); 7 print $arr['foo']; // output's bar
|
2022-07-18
2022-08-17
2022-11-06
2022-08-17
2022-08-15
请发表评论