spfoonnewb Posted December 23, 2006 Share Posted December 23, 2006 Hi,So I have this random script.. it works.What I want it to do is to select 10 files in a directory, (Or select 10 strings in an array on the same page), and display them, but they cannot repeat.. Possible?[code]<?php$txt_array = Array();$my_dir = "includes/"; //Replace it with your frase's directory (dont'n delete the slash) if ($dir = @opendir("$my_dir")) { while (($file = readdir($dir)) !== false) { if ($file != "." && $file != ".." && !is_dir($my_dir.$file)) { /* echo $my_dir.$file."<br>"; DEBUG show file list */ $txt_array[] = $file; } } closedir($dir); }$random_number=rand(0, count($txt_array)-1); $random_txt=$txt_array[$random_number];include($my_dir.$random_txt);?>[/code] Link to comment https://forums.phpfreaks.com/topic/31666-random-script/ Share on other sites More sharing options...
trq Posted December 23, 2006 Share Posted December 23, 2006 [quote]Possible?[/quote]Sure is. Link to comment https://forums.phpfreaks.com/topic/31666-random-script/#findComment-146786 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.