Access JSON object name in PHP

后端 未结 4 1816
孤城傲影
孤城傲影 2020-12-06 06:33

I have the following JSON:

{
  \"nickname\": \"xadoc\",
  \"level\": 4,
  \"loc\": \"Tulsa, OK, USA\",
  \"score\": 122597,
  \"money\": 29412.5,
  \"street         


        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-06 07:05

    I would imagine that the simplest thing to do is to decode into associative arrays instead of stdClass objects

    $obj2 = json_decode( $json, true );
    
    foreach ( $obj2['streets'] as $coords => $street )
    {   
      echo $coords;
    }
    

提交回复
热议问题