Sunday, 15 August 2010

strpos - Can't read correctly from a .txt file in php -



strpos - Can't read correctly from a .txt file in php -

i'm trying read text file downloaded www.groupsort.com

the format looks this:

name rank team mike 1 team 2 charlie 5 team 1 joe 3 team 1 david 21 team 3

also don't know if related, when went pico file, wouldn't show me clear text, bunch of garbage, it's .txt file. weird?

so want usernames , store them in variable. shouldn't work?

$file = "peopletomove.txt"; $fh = fopen($file,'r'); $movetsusers = array(); while (!feof($fh)) { $line = fgets($fh); echo $line."\n"; $name = strpos($line, " "); $name2 = substr($line, 0, $name); echo $name2."\n";

you have tab-separated values. separate on tab:

while(!feof($fh)) { $line = trim(fgets($fh)); if( !$line) continue; // blank line list($name,$rank,$team) = explode("\t",$line); }

php strpos

No comments:

Post a Comment