note 28974 deleted from function.file by irchtml
| From: | irchtml@php.net | Date: | Wed, 11 Feb 2004 07:30:57 +0000 |
| Subject: | note 28974 deleted from function.file by irchtml | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-65000@lists.php.net to get a copy of this message | ||
Note Submitter: dosn@n-net.org
----
refering to the comment of omar dot speranza at argomedia dot it:
---------
$line = mt_rand(0,count($file));
echo $file[$line];
---------
count gives the number of elements $file contains.
The first element of the array is $file[0].
The last element is $file[(count($file)-1)].
If the value created by mt_rand is count($file), $file($line) is empty.
So the above doesn't work correctly.
To avoid getting an empty string, you should use this:
$line = mt_rand(0, (count($file)-1));