Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何从这个URL获取JSON数据?_Php_Json - Fatal编程技术网

Php 如何从这个URL获取JSON数据?

Php 如何从这个URL获取JSON数据?,php,json,Php,Json,我有一个返回JSON对象的URL,如下所示: {"ip":"192.168.48.68"} 我想获得ip值。那么如何通过PHP检索它呢?使用json\u decode方法: $json = YOUR_JSON_OBJECT; $ip = json_decode($json, true); //then you can get the ip using its index in the array $ip["ip"] //192.168.48.68 使用json\u decode方法: $js

我有一个返回JSON对象的URL,如下所示:

{"ip":"192.168.48.68"}

我想获得
ip
值。那么如何通过PHP检索它呢?

使用
json\u decode
方法:

$json = YOUR_JSON_OBJECT;
$ip = json_decode($json, true);
//then you can get the ip using its index in the array
$ip["ip"] //192.168.48.68

使用
json\u decode
方法:

$json = YOUR_JSON_OBJECT;
$ip = json_decode($json, true);
//then you can get the ip using its index in the array
$ip["ip"] //192.168.48.68