note 5553 deleted from ref.array by jeroen
| From: | jeroen@php.net | Date: | Wed, 29 Aug 2001 17:49:31 +0000 |
| Subject: | note 5553 deleted from ref.array by jeroen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-17335@lists.php.net to get a copy of this message | ||
I created a function to return a two-dimensional array, containing the parsed contents of a text
file. The format of the text file is:
username,f34d76asd6542hfg54387634
username2,d8937f98f73987fkjs3498
I wanted the array to be something like
$userdb[0][user] = username
$userdb[0][pass_hash] = f34d76as...
I was able to figure it all out myself. Here's the solution, if anyone's interested:
function Users2array() {
$f = fopen("./userdb", "r");
$i = -1;
while (!feof($f)) {
$i++;
$user = explode(",", fgets($f, 4096));
$db[$i]["user"] = $user[0];
$db[$i]["hash"] = trim($user[1]);
}
return $db;
}