经常调用一个借口之后 返回的内容是json串,利用php函数json_decode() 解析json串之后得到的 数据类型为object(stdclass) 这是一个对象,要取其中的内容也可以 取得,利用object-属性 可以取得,但是习惯数组处理数据,下面是一个object(stdclass)转成 数组
经常调用一个借口之后 返回的内容是json串,利用php函数json_decode() 解析json串之后得到的 数据类型为object(stdclass)
这是一个对象,要取其中的内容也可以 取得,利用object->属性 可以取得,但是习惯数组处理数据,下面是一个object(stdclass)转成 数组的函数
function object_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; }
其实json_decode()想要解析返回结果为数组,需要加上第二个参数TRUE
stdclass 是zend的一个预留类,它是一个空类,没什么内容,php所有的类都继承了这个类,也就是说它是所有类的父类。当PHP中一个类没有明确父类时,成为一个孤儿类时,会被stdclass收留的。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Mac version
God-level code editing software (SublimeText3)