且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将对象转换为数组?

更新时间:2023-02-14 11:49:12

您应该查看

You should look at get_object_vars , as your properties are declared private you should call this inside the class and return its results.

请注意,对于像字符串这样的原始数据类型,它会很好用,但我不知道它在嵌套对象中的表现.

Be careful, for primitive data types like strings it will work great, but I don't know how it behaves with nested objects.

在您的情况下,您必须执行类似操作;

in your case you have to do something like;

<?php
   print_r(get_object_vars($response->response->docs));
?>