php 中如何将对象转换为数组?例如,这里我想将 $result 变量转换为数组。这是代码:$statement = $adapter->createStatement('SELECT * FROM `users`');$result = $statement->execute();$result = new JsonModel($result);$result = array($result);var_dump($result);return ($result);```It produces the following output. array(1) { [0]=> object(Laminas\View\Model\JsonModel)#160 (8) { ["captureTo":protected]=> NULL ["jsonpCallback":protected]=> NULL ["terminate":protected]=> bool(true) ["children":protected]=> array(0) { } ["options":protected]=> array(0) { } ["template":protected]=> string(0) "" ["variables":protected]=> array(4) { [0]=> array(3) { ["id"]=> string(1) "1" ["name"]=> string(13) "J. K. Rowling" ["deleted"]=> string(1) "0" } [1]=> array(3) { ["id"]=> string(1) "2" ["name"]=> string(19) "George R. R. Martin" ["deleted"]=> string(1) "0" } [2]=> array(3) { ["id"]=> string(1) "3" ["name"]=> string(16) "J. R. R. Tolkien" ["deleted"]=> string(1) "0" } [3]=> array(3) { ["id"]=> string(1) "4" ["name"]=> string(12) "Donald Trump" ["deleted"]=> string(1) "0" } } ["append":protected]=> bool(false) } }
- 2 回答
- 0 关注
- 121 浏览
添加回答
举报
0/150
提交
取消