Re: A problem with fgets()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> I just need to figure out why when using fgets() with fseek() &
> rand(), the script returns partial strings form the city names.

Because fseek doesn't necessarily put you at the start of a line.

It puts you anywhere (which could be the start, middle, 3 chars from the
end) according to the number of bytes you tell it to start at.

Then fgets reads the rest of the line.

A file that looks like this:

(numbers are the "bytes" for ease of explanation)

123456789

is going to be different to a file that looks like this:

1234
56
789

and if you tell me you want to start at "byte 5", then in file 1, that's
the middle - in file 2 that's the start of the second line (#4 is a
newline char :P).

-- 
Postgresql & php tutorials
http://www.designmagick.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux