note 5553 modified in Array functions by ronabop

From: Date: Sun, 03 Sep 2000 09:22:39 +0000
Subject: note 5553 modified in Array functions by ronabop
Groups: php.notes 
Request: Send a blank email to php-notes+get-3982@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; } http://www.php.net/manual/array-functions.php

« previous php.notes (#3982) next »