Adressing PHP array decoded from JSON

后端 未结 1 1269
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-19 12:52

I\'m loading a JSON array and decode it to an PHP array

$jsonfile = file_get_contents(\'https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&s         


        
相关标签:
1条回答
  • 2021-01-19 13:23

    This is because json_decode() with no parameters attempts to convert your json string to an stdClass object. If you want to convert it to an array, you need to set the 2nd parameters (the $assoc boolean) to true:

    $json = file_get_contents('LINK TO JSON OUTPUT'); 
    $array = json_decode($json, true); 
    
    0 讨论(0)
提交回复
热议问题