我有来自 Web 服务的 JSON 数据,并使用将其解码为关联数组
$data = json_decode($postdata, true);
using print_r($data);
大批
(
[0] => Array
(
[id] => 1
[cityName] => London
[cityState] => London
[cityPopulation] => 8173194
[country] => United Kingdom
)
[1] => Array
(
[id] => 2
[cityName] => Bombay
[cityState] => Maharashtra
[cityPopulation] => 12478447
[country] => India
)
[2] => Array
(
[id] => 3
[cityName] => Kuala Lumpur
[cityState] => Federal Territory
[cityPopulation] => 1627172
[country] => Malaysia
)
[3] => Array
(
[id] => 4
[cityName] => New York
[cityState] => New York
[cityPopulation] => 8336697
[country] => United States
)
[4] => Array
(
[id] => 5
[cityName] => Berlin
[cityState] => Berlin
[cityPopulation] => 3538652
[country] => Deutschland
)
)
我想将每四个数组的 id、cityName、cityName、cityState、cityPopulation、country 中的每一个插入到现有的 mysql 数据库中。