How to access object properties with names like integers?

后端 未结 7 947
故里飘歌
故里飘歌 2020-11-21 22:14

I am using json_decode() something like:

$myVar = json_decode($data)

Which gives me output like this:

[highlig         


        
7条回答
  •  北荒
    北荒 (楼主)
    2020-11-21 22:49

    I had copied this function from the net. If it works as it says ("Function to Convert stdClass Objects to Multidimensional Arrays"), try the following:

    
    
    • first pass your array to objectToArray function
    • then take the return value
    • echo [highlighting][448364][Data][0]

    Source: PHP stdClass to Array and Array to stdClass

提交回复
热议问题