itmo-php-course/AXIOS/portial.php

53 lines
1.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
define('LIMIT', 5);
define('OFFSET', 0);
$arrMusic = [
'Открываем',
'набор',
'на',
'оплачиваемую',
'стажировку',
'Вы',
'спрашивали',
'вы',
'ждали',
'и',
'вот',
'мы',
'возвращаемся',
'с',
'анонсом',
'стажировки',
'для',
'разработчиков!',
'6 месяцев',
];
$len = sizeof($arrMusic);
// $limit = $_GET['limit'] or LIMIT;
$limit = isset($_GET['limit']) ? $_GET['limit'] : LIMIT;
// $offset = $_GET['offset'] or OFFSET;
$offset = isset($_GET['offset']) ? $_GET['offset'] : OFFSET;
$portial = array_slice($arrMusic, $offset, $limit);
// print($len);
$str = '<ul>';
foreach ($portial as $value) {
$str .="<li>$value</li>";
}
$str .= '';
// $countPage = intdiv($len , $limit);
// // var_dump($countPage);
// $paginator = '';
// for ($i = 0; $i < $countPage; $i++) {
// $paginator .= '<a href= "page.php?offset='.LIMIT*$i.'&limit='.LIMIT.'">'.$i.'</a>&nbsp;';
// }
header('Content-Type: plan/text; charset=utf-8');
echo ($str);