jeudi 19 avril 2018

random(non- repeating) file generator on click of button in php

i want to display 5 php files content randomly but non repeating when clicked a button [NEXT] using php/javascript (that works in php desktop as well).

i did used php random function in header statement :- it did displayed random web page on page load but i did came across repeated web page

this is the code i used for index.php file:

<?php
$RandomList = array();
$RandomList[] = "/review/review-a1.php";
$RandomList[] = "/review/review-a2.php";
$RandomList[] = "/review/review-a3.php";
$RandomList[] = "/review/review-a4.php";
readfile($_SERVER['DOCUMENT_ROOT'].$RandomList[rand(0,count($RandomList)-1)]);
?>

please suggest how to get non repeated files .




Aucun commentaire:

Enregistrer un commentaire