Re: Array help

From: Date: Sun, 04 Mar 2007 14:34:09 +0000
Subject: Re: Array help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-249802@lists.php.net to get a copy of this message
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

« previous php.general (#249802) next »