Jump to content

Archived

This topic is now archived and is closed to further replies.

thindery

displaying random page

Recommended Posts

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.