thefollower Posted December 24, 2007 Share Posted December 24, 2007 I had the idea of randomly echo'in a certain text on a random page of the entire site... (with exlcuding lists ) so that it will show on page that the user can actually access... What i was thinking was in my global include randomize what page it should be... but wondered would i have to physically hard code each page url for it to choose or is there a built in function which can scan through the root folder and pick at random? And then after that find a way to do "if user is view "this url" ... echo 'stuff'" ? Quote Link to comment https://forums.phpfreaks.com/topic/82994-idea-i-have-but-is-it-possible/ Share on other sites More sharing options...
marcus Posted December 24, 2007 Share Posted December 24, 2007 <?php $string = 'monkeys pie potato grape loser lemonade woot pie'; $ex = explode("\n",$string); shuffle($ex); echo $ex[rand(0,count($ex))]; ?> Random line from the string variable. You can include a text file instead. So like: <?php $file = file('this-file.txt'); shuffle($file); echo $file[rand(0,count($file))]; ?> Quote Link to comment https://forums.phpfreaks.com/topic/82994-idea-i-have-but-is-it-possible/#findComment-422122 Share on other sites More sharing options...
thefollower Posted December 24, 2007 Author Share Posted December 24, 2007 How does it know what php scrip the user is viewing is that what file('this-file.txt'); is? which i will assume is built in function ? Also won't the strings require the .php tag at the end ? Quote Link to comment https://forums.phpfreaks.com/topic/82994-idea-i-have-but-is-it-possible/#findComment-422125 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.