<?php
$data = json_decode(file_get_contents("https://developerhub.alfabank.by:8273/partner/1.0.0/public/rates"), true);
$result = ['usd' => 0, 'rub' => 0];
foreach ($data['rates'] as $rate) {
if ($rate['sellIso'] == "USD" && $rate['buyIso'] == 'RUB') {
$result['rub'] = $rate['buyRate'];
}
if ($rate['sellIso'] == "EUR" && $rate['buyIso'] == 'USD') {
$result['usd'] = $rate['buyRate'];
}
}
echo json_encode($result);
/*
{"usd":1.23,"rub":76}
*/
function get_prod_all() {
global $link;
return mysqli_query($link,"SELECT * FROM ostor_apple");
}
$prods = get_prod_all();
while($prod = mysqli_fetch_array($prods)){
echo $prod['title'];
}
<?php
$foo = "bar\nbaz".PHP_EOL."bat
qux";
$url = urlencode($foo);
echo $url;
$response = file_get_contents($url);
echo $response;