Welcome to HBH! If you had an account on hellboundhacker.org you will need to reset your password using the Lost Password system before you will be able to login.

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