Просмотр поста

.
Rakovskiy
The Fast, Secure and Professional - Yii2
# SPONGE (03.01.2016 / 17:05)
куда именно добавить?
function nextKey(array $array, $cookieKey){
    $myKey = isset($_COOKIE[$cookieKey]) ? abs($_COOKIE[$cookieKey]) : 0;
    $nextKey = isset($array[$myKey]) && isset($array[$myKey + 1]) ? $myKey + 1 : 0;
    setcookie($cookieKey, $nextKey, time() + 86400);

    return $nextKey;
}



// Впиши сюда правильные URL
$files = [
    'http://site.name/zapros/1zapros.php',
    'http://site.name/zapros/2zapros.php',
    'http://site.name/zapros/3zapros.php',
];

$key = nextKey($files, 'slider');
$path = isset($files[$key]) ? $files[$key] : null;

if ($path && is_file($path)){
    $items = unserialize(file_get_contents($path));

    foreach ($items as $item){
        if (is_string($item) && mb_strlen($item) < 2){
            continue;
        }

        $label = str_replace('-', ' ', $item);
        echo '<li><b><a href="/' . $item . '/">' . $label . '</a></b></li>';
    }
}