On Wednesday 17 July 2002 00:44, Dave [Hawk-Systems] wrote:

> >  if(in_array($HTTP_SERVER_VARS["REMOTE_USER"] . "\n", $users)) { ... }

> >BTW, it should be:
> >
> >  fwrite ($fd, join('', $users));
> >
> >otherwise each time you write the file out it will have an increasing
> > number of "\n" attached to each user.
>
> thats the crux...
>       fwrite ($fd, join('', $users));
> results in a long string of usernames in the, which can't be grabbed back
> into the array with the file... 

How would it? Each element in $users have a trailing "\n".

> in short, there is no way to trim as you
> file() to eliinate this (from what i can see) other than running it through
> each() or something and rebuilding the array after trimming.  Was hoping
> for something a little more eloquent.

Start from scratch. You have a file with a single user on each line:

tom\n
dick\n
harry\n

You use file() to read into array $users.

You compare as in above.

You add a user by:

  $users[] = "NEW_USER\n";

You write out the file as above.

If my logic haven't gone awry somewhere, that's your problem solved!

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
It is better to have loved and lost than just to have lost.
*/


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

Reply via email to