I'm trying to build something like https://coinranking.com/. I plan on doing this by sorting the results from the API at http://www.coincap.io/front using the position24 value as sorting parameter.
So far, I managed to pull an ordered list with the prices, but I'd like to display the values from other objects (volume, mktcap, etc) as well in a table. Would I have to repeat this function for every object?
<php?
function compare($a, $b) {
return intval($a->position24) - intval($b->position24);
}
$json = file_get_contents('http://www.coincap.io/front');
$data = json_decode($json);
usort($data, 'compare');
foreach ($data as $item) {
echo $item->price . "\n"<;
}
?>