Answer the question
In order to leave comments, you need to log in
How to make an array from cookies?
There are cookies with API exchange rates. You need to write them to an array, or write them to a file so that in the future this data can be read.
$ec = $model->getMass(11); //возврящает курс валют
define('LINK', 'https://api.privatbank.ua/p24api/pubinfo?json&exchange&coursid=');
setcookie('Name', $ec, time() + 36000);
function getMass($num) {
$url = urldecode(LINK . $num);
$impl = implode(file($url));
$decode = json_decode($impl, true);
foreach($decode as $decod) {
if($decod['ccy'] == 'USD') {
$val = $decod['buy'];
break;
}
}
return($val);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question