This link link generates an array, would you like to import it into a local array, how do I?
I tried to do it:
$url = "https://api.coinmarketcap.com/v1/ticker/";
function curl_get_contents($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data[] = curl_exec($ch);
curl_close($ch);
return $data;
}
$contents = curl_get_contents($url);
echo count($contents); // 1
But only one index with all the arrays inside it is created, the result is 1, I would like to keep the count number of $ contents for the number of indexes of the URL.