thindery Posted February 13, 2003 Share Posted February 13, 2003 i\'ve been looking at the functions of rand() and srand(), and im not fully getting it. i would like to do something that will pick a random .php file from a folder. does ne one know of a tutorial that would be useful to me? or just post it here. thanks tylor Quote Link to comment https://forums.phpfreaks.com/topic/147-displaying-random-page/ Share on other sites More sharing options...
metalblend Posted February 13, 2003 Share Posted February 13, 2003 You may want to refer to this thread: http://forums.phpfreaks.com/viewtopic.php?t=1946 Here\'s a solution you can use for this situation: Make an array of possible pages and randomly select a key. [php:1:9dc168d5bd]$arr = Array(\\\"pg1.php\\\",\\\"pg2.php\\\",\\\"pg3.php\\\",\\\"pg4.php\\\",\\\"pg5.php\\\"); srand((double)microtime()*1000000); $rand = rand(0,(sizeOf($arr)-1)); $file = $arr[$rand]; include($file);[/php:1:9dc168d5bd] Hope that helps. Quote Link to comment https://forums.phpfreaks.com/topic/147-displaying-random-page/#findComment-445 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.