How do I convert an array of PHP objects into a normal array?
How do I convert an array of PHP objects into a normal array?
?
In the use of jquery Easyui framework for program development, encountered in the foreground of the JSON format data passed to the server backstage, the PHP Json_decode function converted into an array due to an array of objects, PHP program can not be normal processing of data, To do this, you need to develop a PHP callback function (Objarray_to_array) to convert an array of objects into a normal array.
?
/** * Object array to normal array * * The JSON string that is submitted to the background by Ajax is decode decoded to an object array, * This must be converted to a normal array for subsequent processing, * This function supports multidimensional array processing. * * @param array * @return array */function objarray_to_array ($obj) { $ret = array (); foreach ($obj as $key + $value) {if (GetType ($value) = = "Array" | | GetType ($value) = = "Object") { $ret [$key] = Objarray_to_array ($value);} else{ $ret [$key] = $value;} } return $ret;}
?