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... Link to comment https://forums.phpfreaks.com/topic/109096-getting-things-from-a-specific/ 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]; ?> Link to comment https://forums.phpfreaks.com/topic/109096-getting-things-from-a-specific/#findComment-559672 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.