Merhaba aşağıdaki kod bloğunu kullanıyorum, ama gelen verileri foreach ile dönemedim bir türlü. Yardımcı olabilecek varmı acaba.
<?php
try {
$baglanti = new PDO('mysql:host=localhost;dbname=dbadi', "dbkullanici", "dbsifre");
$baglanti->exec("SET NAMES 'utf8'; SET CHARSET 'utf8'");
//read the json file contents
$jsondata = file_get_contents('https://google.com');
$data = json_decode($jsondata, TRUE);
$cityid = $data['data']['0']['CityID'];
$cityname = $data['data']['0']['CityName'];
$countpharmacy1 = $data['data']['0']['countPharmacy'];
$areaname = $data['data']['0']['area'][0]['areaName'];
$countpharmacy2 = $data['data']['0']['area'][0]['countPharmacy'];
$name = $data['data']['0']['area'][0]['pharmacy'][0]['name'];
$phone = $data['data']['0']['area'][0]['pharmacy'][0]['phone'];
$address = $data['data']['0']['area'][0]['pharmacy'][0]['address'];
$map = $data['data']['0']['area'][0]['pharmacy'][0]['maps'];
$ayar=$baglanti->prepare("INSERT INTO nobetcieczaneler(cityid, cityname, countpharmacy1, areaname, countpharmacy2, name, phone, address, map)
VALUES('$cityid', '$cityname', '$countpharmacy1', '$areaname', '$countpharmacy2', '$name', '$phone', '$address', '$map')");
$ayar->execute(array(2));
$ayarcek=$ayar->fetch(PDO::FETCH_ASSOC);
echo "Bağlantınız Başarı İle Gerçekleşti!";
$baglanti = null;
} catch (PDOException $e) {
print "Hata!: " . $e->getMessage() . "<br/>";
die();
}
?>