Skip to main content

I have been on this but i can't get it working. How to display the name and price of coin lists form this api [closed]

My code

<?php

$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_URL => "https://api.coinpaprika.com/v1/tickers",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_SSL_VERIFYHOST => 0,
    CURLOPT_SSL_VERIFYPEER => 0, ));

$response = curl_exec($curl);
curl_close($curl);

//var_dump($response);
$result = json_decode($response, true);

echo $result['name'];

?>

Var dump is displaying the datas fine

I receive this message.

Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\dashboard\index.php on line 158



source https://stackoverflow.com/questions/68975688/i-have-been-on-this-but-i-cant-get-it-working-how-to-display-the-name-and-pric

Comments