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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php