1

После выполнения следующего кода:

<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.cloudflare.com/client/v4/zones');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');


$headers = array();
$headers[] = 'X-Auth-Email: nh***@gmail.com';
$headers[] = 'X-Auth-Key: 99c22d**741201e77fc9948f1286c9b8';
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
curl_close($ch);
$event_json = json_decode($result, true);
echo $event_json ["result"]["0"]["id"] . "<br>" ; 
echo $event_json ["result"]["0"]["name"] . "<br>" ;


?>

Получаю только по одному id и name:

7ca47d86d0f56fe45ad01edb6c4c7771
airbeautty.xyz

Как вывести все id и name ?

1 ответ 1

1
$event_json = json_decode($result, true);
foreach($event_json["result"] as $result){
    echo $result['id'];
    echo $result['name'];
}

Это должно подойти

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.