A
A
Andrey Chugunov2020-02-28 21:50:15
PHP
Andrey Chugunov, 2020-02-28 21:50:15

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

1 answer(s)
C
Cat in coat, 2020-02-28
@kostarev_v

Did you understand what you asked?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question