How do I convert an object to an array?

后端 未结 11 1394
别那么骄傲
别那么骄傲 2020-11-22 10:36
response->docs);
?>

Outputs the following:

    Array 
(
    [0] => Object 
            (         


        
11条回答
  •  迷失自我
    2020-11-22 11:02

    You can quickly convert deeply nested objects to associative arrays by relying on the behavior of the JSON encode/decode functions:

    $array = json_decode(json_encode($response->response->docs), true);
    

提交回复
热议问题