blufish Posted June 7, 2008 Share Posted June 7, 2008 Ok, heres my problem... I want to randomly select a random line from a file, but the first and last lines, I do not want to select randomly, how to I achieve this? ??? Edit: to be more clear I want to select a random line from a file except for the first couple lines and the last couple lines... Quote Link to comment Share on other sites More sharing options...
sasa Posted June 7, 2008 Share Posted June 7, 2008 try <?php $lines = file('filename'); $key = rand(2, count($lines) - 3); echo $lines[$key]; ?> Quote Link to comment 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.