Re: Array help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey Stut,
Thanks for replying.

Will be making two versions, one with a DB and one to work with the file for the old school folks who dont want to convert their file and use "new fangled" databases... some people its easier to just not argue or try to convince...
and however stupid someone's opinion is, they are still entitled to it...esp when you are thinking of (maybe) selling a future product it does not make much sense telling them they are stupid :-))

"If you *need* to stick to using the file, are you looking for a 
particular username or just want to load the whole list?"

I'm looking to match a login (user:pass)... so I would need to load the whole list right? or do you have an alternative idea? am totally open to suggestions and alternatives at this point... just looking for the easiest way in terms of server load and processing..which is why I am trying to avoid a for() or while() loop.

Thanks!
Ryan

Stut <stuttle@xxxxxxxxx> wrote: Ryan A wrote:
> I have a login/password file with these kind of  values:
> user1:pass1
> user2:pass2
> cat:dog
> love:hate
> 
> I have  opened the file and put it into an array with this code:
> (thanks to richard lynch from this list for idea and code snippets)
> 
> $file =  file_get_contents('a.htpasswd');
> preg_match_all('/(.*):(.*)$/msU', $file,  $htpassd);
> 
> but how do I get it into this format  :
> 
> $users['username'] = 'password'
> 
> without using a loop? I was  thinking something like array_flip or array_splice??
> (The reason I dont want to use a loop (for,while) is there can be thousands of user:pass combos in the files and thousands of logins and attempted logins a day)

My advice would be to swap to using a database. With that number of 
users it's going to give you a huge boost in performance. SQLite would do.

If you *need* to stick to using the file, are you looking for a 
particular username or just want to load the whole list?

-Stut



------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
 
---------------------------------
Now that's room service! Choose from over 150,000 hotels 
in 45,000 destinations on Yahoo! Travel to find your fit.

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux