I'm trying to use the <?php echo
command in welcome.blade.php but do not know the right syntax
Tried all the workarounds but nothing
<div class="col">
@php
$decoded_json =json_decode(file_get_contents("https://api.coinmarketcap.com/v1/ticker/"), TRUE);
function price($curr) {
global $decoded_json;
$js = array_column($decoded_json, 'price_usd', 'id');
return $js[$curr];
}
@endphp
<body>
BTC $<?php echo price("bitcoin");?>
<br />
LTC $<?php echo price("litecoin"); ?>.
<br />
XMR $<?php echo price("monero"); ?>.
</body>
The code in between @php & @endphp works fine but when i add <?php echo string throw a 500 error
Edit: I now have
<center><h2>BTC $<?php= price("bitcoin");?></h2></center>
<center><h2>LTC $<?php= price("litecoin");?></h2></center>
<center><h2>XMR $<?php= price("monero");?></h2></center>
Page loads, but no values load. What am I doing wrong?
BTC $= price("bitcoin");?> | LTC $= price("litecoin");?> | XMR $= price("monero");?>