RE: [PHP] file() and array values contain extra \n

2002-07-16 Thread Dave [Hawk-Systems]
>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. curious... when I ran through that (bef

Re: [PHP] file() and array values contain extra \n

2002-07-16 Thread Jason Wong
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" at

RE: [PHP] file() and array values contain extra \n

2002-07-16 Thread Dave [Hawk-Systems]
>> >> $users[]=$newuser; >> >> # adds the new user to the end of the above created users array >> >> # then write the array to the file >> >> $fd = fopen (".users", "w+"); >> >> fwrite ($fd, join("\n",$users)); >> >> fclose ($fd); >> >> >> >> the problem is after adding users, only the last user r

Re: [PHP] file() and array values contain extra \n

2002-07-16 Thread Jason Wong
On Tuesday 16 July 2002 22:35, Dave [Hawk-Systems] wrote: > >> $users[]=$newuser; > >> # adds the new user to the end of the above created users array > >> # then write the array to the file > >> $fd = fopen (".users", "w+"); > >> fwrite ($fd, join("\n",$users)); > >> fclose ($fd); > >> > >> the

RE: [PHP] file() and array values contain extra \n

2002-07-16 Thread Dave [Hawk-Systems]
>On Tuesday 16 July 2002 21:53, Dave [Hawk-Systems] wrote: >> $users=file('.users'); >> # puts users in the file into an array so we can >> # check for valid or priv users with >> if(in_array($HTTP_SERVER_VARS["REMOTE_USER"], $users)){} >> >> # we add additional users to the .users file with the f

Re: [PHP] file() and array values contain extra \n

2002-07-16 Thread Jason Wong
On Tuesday 16 July 2002 21:53, Dave [Hawk-Systems] wrote: > $users=file('.users'); > # puts users in the file into an array so we can > # check for valid or priv users with > if(in_array($HTTP_SERVER_VARS["REMOTE_USER"], $users)){} > > # we add additional users to the .users file with the followin