ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
查询构造器结果--对象数组互转方法 ~~~ /** * 数组转换对象 * * @param $e 数组 * @return object|void */ public function arrayToObject($e) { if (gettype($e) != 'array') return; foreach ($e as $k => $v) { if (gettype($v) == 'array' || getType($v) == 'object') $e[$k] = (object)$this->arrayToObject($v); } return (object)$e; } /** * 对象转换数组 * * @param $e StdClass对象实例 * @return array|void */ public function objectToArray($e) { $e = (array)$e; foreach ($e as $k => $v) { if (gettype($v) == 'resource') return; if (gettype($v) == 'object' || gettype($v) == 'array') $e[$k] = (array)$this->objectToArray($v); } return $e; } ~~~