$end) { echo 'Invalid range!'; http_response_code(400); exit(0); } $len = count($LIBRARY_INFO['albums']); if ($start >= $len) { return array(); } if ($end >= $len) { $end = $len - 1; } $albums = []; for ($i = $start; $i <= $end; ++$i) { $albums[] = new Album($LIBRARY_INFO['albums'][$i]); } return $albums; } switch ($method) { case 'HEAD': case 'GET': $albums = get_albums(); foreach ($albums as $album) { echo $album->get_html(); } break; default: echo 'Method not permitted'; http_response_code(405); exit(0); } ?>