我目前正在嘗試在變量中獲取JSON解碼輸出的每個標題這就是對我有用的卷曲$curl = curl_init();curl_setopt_array($curl, array( CURLOPT_URL => 'http://api.irail.be/disturbances/?format=json&lang=nl', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_HTTPHEADER => array( 'cache-control: no-cache', 'content-type: application/x-www-form-urlencoded' ),));$response = curl_exec($curl);$err = curl_error($curl);curl_close($curl);// Decode JSON response and get only the data needed:$response = json_decode($response);$response = $response->disturbance[0];var_dump($response);$name = $response->title;echo $name;當我刪除干擾背后的[0]時,我得到一個空白$name。有誰知道我該如何解決這個問題?謝謝
PHP Curl Json:多個輸出
函數(shù)式編程
2022-08-05 15:59:58