Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.
Output random linefrom file - PHP Code Bank
Output random linefrom file
Similar to the sayings under the HBH logo, this reads and displays random quotes from file.txt.
This uses the much faster mt_rand function, explode can chew up memory for big lists.
<?PHP
/*
Uses mt_rand() for a faster alternative to rand().
*/
$file = file_get_contents('file.txt');
$lines = explode("\n",$file);
echo $lines[mt_rand(0,count($lines)-1)]."\n";
?>
Comments
Sorry but there are no comments to display