JSON-i tagastav API PHP-s

Praegusel ajal kasutavad saidid andmevahetuses JSON-vormingut. Teeme API, mis tagastab andmed selles vormingus.

Olgu meie API näiteks tagastav massiivi, mis on täidetud täisarvudega ühest parameetrist teiseni:

api.loc/index.php<?php
  header('Content-Type: application/json'); // määrame MIME
  
  $arr = range($_GET['num1'], $_GET['num2']);
  echo json_encode($arr);
?>

Kasutame oma API-d:

tst.loc/index.php<?php
  $url = 'http://api.loc/index.php?num1=1&num2=10';
  $res = file_get_contents($url);
  var_dump($res); // andmed JSON-vormingus
?>

Teisendame saadud andmed JSON-vormingust tavaliseks massiiviks:

tst.loc/index.php<?php
  $url = 'http://api.loc/index.php?num1=1&num2=10';
  $res = file_get_contents($url);
  
  $arr = json_decode($res);
  var_dump($arr);
?>
Задание 1

Tehke API, mis tagastab pühade kuupäevade massiivi jooksval aastal.