我正在使用OpenWeather API。我将它保存在$jsonobj
,但不知道如何访问天气细节。我不知道[]
和{}
如何不同以及它们实际上的含义。来自URL的PHP JSON值
我的代码是在这里:
<?php
$name_of_city = "mathura";
$request = 'http://api.openweathermap.org/data/2.5/weather?APPID=my_key&q='.$name_of_city;
$response = file_get_contents($request);
$jsonobj = json_decode($response,true);
print_r($jsonobj);
?>
[用PHP解析JSON文件(可能的重复http://stackoverflow.com/questions/ 4343596 /解析-json-file-with-php) –
请不要吝惜,请避免将文本信息作为图像发布。图片无法搜索,无法复制和粘贴,并且可访问性差。并且请** _从不___以JPEG形式发布文本图像。这是一个可怕的文字格式。如果您绝对必须发布文字图片,请使用PNG。 – Chris