如何使用PHP获取JSON嵌套数组中所有IP地址的long、lat

如何使用PHP获取JSON嵌套数组中所有IP地址的long、lat,php,arrays,json,nested,geolocation,Php,Arrays,Json,Nested,Geolocation,需要修复php代码方面的帮助,希望获得JSON数组中所有IP地址的经度和纬度,并将其地理位置数据转储到.csv文件中,或再次以JSON显示 示例JSON数组: [ { "addr": "103.229.122.253:19667", "services": 1, "lastsend": 1578797285, "lastrecv": 1578797285, "conntime": 1577841460, }, { "addr": "21

需要修复php代码方面的帮助,希望获得JSON数组中所有IP地址的经度和纬度,并将其地理位置数据转储到.csv文件中,或再次以JSON显示

示例JSON数组:

[
  {
    "addr": "103.229.122.253:19667",
    "services": 1,
    "lastsend": 1578797285,
    "lastrecv": 1578797285,
    "conntime": 1577841460,
  },
  {
    "addr": "212.239.222.147:19667",
    "services": 1,
    "lastsend": 1578797395,
    "lastrecv": 1578797395,
    "conntime": 1577841462,
  },
  {
    "addr": "[2602:ffc5:20::1:63b5]:19667",
    "services": 1,
    "lastsend": 1578797381,
    "lastrecv": 1578797381,
    "conntime": 1577936686,
    "banscore": 0
  }
]
<?php

ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);

// Read JSON file
$readjson = file_get_contents('*extenal link to get JSON data*') ;

//Decode JSON
$data = json_decode($readjson, true);

foreach ($data as $emp) {
echo  $emp['addr'] .",";
}
echo "<br/>";

?>
PHP代码:

[
  {
    "addr": "103.229.122.253:19667",
    "services": 1,
    "lastsend": 1578797285,
    "lastrecv": 1578797285,
    "conntime": 1577841460,
  },
  {
    "addr": "212.239.222.147:19667",
    "services": 1,
    "lastsend": 1578797395,
    "lastrecv": 1578797395,
    "conntime": 1577841462,
  },
  {
    "addr": "[2602:ffc5:20::1:63b5]:19667",
    "services": 1,
    "lastsend": 1578797381,
    "lastrecv": 1578797381,
    "conntime": 1577936686,
    "banscore": 0
  }
]
<?php

ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);

// Read JSON file
$readjson = file_get_contents('*extenal link to get JSON data*') ;

//Decode JSON
$data = json_decode($readjson, true);

foreach ($data as $emp) {
echo  $emp['addr'] .",";
}
echo "<br/>";

?>

Nice教程可能会对array\u专栏有所帮助?为什么不使用get addr?