stdClass to array?

后端 未结 11 1832
情话喂你
情话喂你 2020-12-03 05:05

i have:

stdClass Object
(
    [0] => stdClass Object
        (
            [one] => aaa
            [two] => sss
        )

    [1] => stdClass O         


        
11条回答
  •  情歌与酒
    2020-12-03 05:45

    If you have an nested array you can used json_encode and json_decode to convert the whole object to an array:

    $result = json_decode(json_encode($source), JSON_OBJECT_AS_ARRAY);
    

提交回复
热议问题