当我把这个http://api.hostip.info/get_json.php放在url栏中时,它给我一个这种格式的数组如何从中提取信息?
{"country_name":"PAKISTAN","country_code":"PK","city":"Lahore","ip":"180.178.147.131"}
答案 0 :(得分:0)
在PHP中使用json_decode()
<?php
$jsonstringfromyourapi='{"country_name":"PAKISTAN","country_code":"PK","city":"Lahore","ip":"180.178.147.131"}';
$arr=json_decode($jsonstringfromyourapi,1);
foreach($arr as $k=>$v)
{
echo "$k = $v<br>";
}