>>Can anyone show me how to split() each line and parse to see if $user exists?<<
// get contents of a file into a string $filename = "./users.txt"; $fd = fopen ($filename, "r"); $contents = fread ($fd, filesize ($filename)); fclose ($fd); // seperate the string into an array of lines $linebreak = "\n"; $lines = explode($linebreak,$contents); // seperate each line into an array of words for ($i=0;$i<count($lines);$i++){ $words[$i]=explode(" ",$lines[$i]); } ----- Original Message ----- From: "jtjohnston" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, December 20, 2001 10:59 PM Subject: Re: [PHP] Beginner question? Michael, $fp = fopen ("./users.txt", "r"); while (!feof ($fp)) { $buffer = fgets($fp, 4096); echo $buffer; } fclose($fp); Ok. But $buffer is not an array, is it? Why/what is 4096? What is !feof ? Can anyone show me how to split() each line and parse to see if $user exists? Here's what I'm upto. I want to use users.txt as a user:password text database file. I want to read users.txt into an array. I want to parse each line splitting for ":" user:pass john:help michael:thanks $fp = fopen ("./users.txt", "r"); while (!feof ($fp)) { $buffer = fgets($fp, 4096); echo $buffer; } fclose($fp); $user = "john"; $num_fields = count($buffer); for ($i = 0; $i < $num_fields; $i++) { if ?? = $user then echo ?? } Can anyone show me how to split() each line and parse to see if $user exists? > ><?php > >$fp = fopen ("./info.txt", "r"); > >print $fp; > >fclose($fp); > >?> > $fp is just a file pointer, not the actual contents of the file. You need > to use fgets() (or something similar) to actually get the contents out. > http://www.php.net/manual/en/function.fgets.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]