I'm trying to generate a random number based on the size of a file (which happens to be dictionary with each word on a separate line). Here's the code I'm using:
$dictionary = "english";
$fp = fopen($dictionary, "r");
$size = filesize($dictionary);
echo "$size | ";
// go to a random location in the dictionary
srand ((double) microtime() * 1000000);
$rand_location = rand(0, $size);
echo "$rand_location ";
fseek($fp, $rand_location);
==================================
$size is showing 172602, but $rand_location outputs either 0, 1, or 2 only. What's going on here? I'm using php v4.2.2. I know srand isn't necessary for this version of php, but even when I comment that line out, I still have the same problem.
Thanks in advance!
Tommy
tmann@unc.edu