如何解析 php 中的 stdClass 对象
How to parse stdClass object in php
Using var_dump from an API call give me the output like this
如何把它们放到一个数组中?谢谢
您可以使用 json_encode
to convert it to a json. After which you can use json_decode
并将第二个参数设置为 true
,这将 return 一个数组而不是 StdObject
。
如果您调用的 api 只是 return 本身就是 json 那么您可以继续使用 json_decode
直接将第二个参数设置为 true
产生相同的结果。
还有其他方法,但这是最简单的。
您可以查看其他问题,like this one or this one。
Using var_dump from an API call give me the output like this
如何把它们放到一个数组中?谢谢
您可以使用 json_encode
to convert it to a json. After which you can use json_decode
并将第二个参数设置为 true
,这将 return 一个数组而不是 StdObject
。
如果您调用的 api 只是 return 本身就是 json 那么您可以继续使用 json_decode
直接将第二个参数设置为 true
产生相同的结果。
还有其他方法,但这是最简单的。
您可以查看其他问题,like this one or this one。