Jump to content


displaying random page

  • Please log in to reply
1 reply to this topic

#1 thindery

  • Members
  • Pip
  • Newbie
  • 4 posts

Posted 13 February 2003 - 03:46 AM

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


#2 metalblend

  • Members
  • PipPipPip
  • Advanced Member
  • 89 posts
  • LocationCalifornia, USA

Posted 13 February 2003 - 03:55 AM

You may want to refer to this thread: http://forums.phpfre...opic.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\\\");
$rand = rand(0,(sizeOf($arr)-1));
$file = $arr[$rand];


Hope that helps.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users