Я пытаюсь расшифровать JSon obtening по CURL с PHP, как это:Как получить JSON из CURL с PHP
$url = 'https://www.toto.com/api/v1/ads/?apikey=titi&code_postal='.$code_postal.'&type_de_bois='.$type_bois;
$cURL = curl_init();
curl_setopt($cURL, CURLOPT_URL, $url);
curl_setopt($cURL, CURLOPT_HTTPGET, true);
curl_setopt($cURL, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept: application/json'
));
$result = curl_exec($cURL);
curl_close($cURL);
var_dump(json_decode($result, true));
echo json_decode($result);
Это возвращает мне, что, то, что, кажется, JSON:
[{"id": "6918", "nom": "X", "code_postal": "88120", "ville": "city", "description": "test", "logo": "test .png "," url ":" test "," phone ": true}, [{" id ":" 6919 "," nom ":" Y "," code_postal ":" 88121 "," ville ": «city1», «description»: «test», «логотип»: «test.png», «url»: «test», «phone»: true}, [{"id": "6920", "nom ":" Z "" code_postal »:« 88122 »,« ville »:« town2 »,« description »:« test »,« логотип »:« test.png »,« url »:« test »,« phone »: true}]
INT (1) 1
Мой вопрос являются: - Почему, без эхо или печати, массив печатается? - Почему json_decode не работает или почему это только одно значение («1»)?
Большое спасибо за ваш ответ.
var_dump() отобразит результат в массиве – Kalaivanan