Twentoh
Новичок
Нужно выполнить все .php файлы в случайном порядке на странице.
Данный код выполняет только один случайный файл:
Как быть?
Данный код выполняет только один случайный файл:
PHP:
<?php
$fictional = glob("folder/*.php");
$max_index = count($fictional) - 1;
$indices = range( 0, $max_index );
if (!isset($_SESSION['indices']) || !isset($_SESSION['current'])) {
shuffle($indices);
$_SESSION['indices'] = serialize($indices);
$_SESSION['current'] = 0;
} else {
$_SESSION['current']++;
}
$indices = unserialize($_SESSION['indices']);
if ($_SESSION['current'] > $max_index) {
shuffle($indices);
$_SESSION['indices'] = serialize($indices);
$_SESSION['current'] = 0;
}
$current = $_SESSION['current'];
$index = $indices[$current];
include($fictional[$index]);
?>