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]

Reply via email to