function price_format($price, $decimals = 2) {
$CI =& get_instance();
$config = $CI->config->item('mcp');
$price = (float) $price;
$formats = ["US" => ['.', ','], "EU" => [',', '.']];
$decimals = ($price >= 1 || $price == 0) ? $decimals : ($price < 0.000001 ? 8 : 6);
return number_format($price, $decimals, $formats[$config['num_format']][0], $formats[$config['num_format']][1]);
$coinfeed_coingecko_json = file_get_contents('https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids='.$t['page.content_slug'].'');
$coinfeed_json = json_decode($coinfeed_coingecko_json, false);
$coinfeed_current_price = $coinfeed_json[0]->current_price;
$coinfeed_current_supply = $coinfeed_json[0]->circulating_supply;
$coinfeedprice_change_percentage_24h = $coinfeed_json[0]->price_change_percentage_24h;
$coinfeed_ath = $coinfeed_json[0]->ath;
?>
<?php echo $coinfeedde = number_format($coinfeed_current_price, 0, '.', '.'); ?>
I created my first api call and now i trying to connect it to my old numbers helper (function price_format).
How can i connect this function with my new api call? If i replace $price it will not work. Thanks for your time guys.