Array help
| From: | Ryan A | Date: | Sun, 04 Mar 2007 14:30:30 +0000 |
| Subject: | Array help | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-249801@lists.php.net to get a copy of this message | ||
Hi!
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)
Suggestions/comments/links too are most welcome.
Cheers!
R
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
---------------------------------
Access over 1 million songs - Yahoo! Music Unlimited.