Don't know why, serialize the array to JSON, and then save it to Redis (string type). And then take it out and deserialize it into an array, it becomes an array of objects.
thinkphp Normal array value $arr[' key '] object array $arr->key
1 /**2 * [Std_class_object_to_array object to group]3 * @param [Stdclass] $stdclassobject [Object]4 * @return [array] [arrays]5 */6 functionStd_class_object_to_array ($stdclassobject)7 {8 $_array=Is_object($stdclassobject) ?Get_object_vars($stdclassobject) :$stdclassobject;9 Ten foreach($_array as $key=$value) { One $value= (Is_array($value) ||Is_object($value)) ? Std_class_object_to_array ($value) :$value; A $array[$key] =$value; - } - the return $array; -}View Code
//Call this function, transform it into an array, and then remove the corresponding valuefunctionObject_array ($array){ if(Is_object($array)) { $array= (Array)$array; } if(Is_array($array)) { foreach($array as $key=$value) { $array[$key] = Object_array ($value); } } return $array;}
PHP converts an array of objects into a normal array