note 52756 deleted from ref.array by didou

From: Date: Thu, 02 Jun 2005 10:19:56 +0000
Subject: note 52756 deleted from ref.array by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-89781@lists.php.net to get a copy of this message
Note Submitter: a dot lang at freenet dot de ---- With help of this function you can save a whole db in an Array. Usage: $sql = mysql_query("SELECT * FROM DB"); $dbarray = sqlar($sql); function sql2ar ($sql, $return = true) { $sql2 = mysql_fetch_assoc($sql); $befehl =""; $keys = array_keys($sql2); for($i2 = 0;$i2 < count($keys);$i2++) { $befehl .= '$array[$i][\''.$keys[$i2].'\'] = $row[\''.$keys[$i2].'\'];'; } mysql_data_seek($sql,0); $i = 0; while($row = mysql_fetch_assoc($sql)) { eval($befehl); $i++; } if($return == true) { return $array; } else { echo "<pre>"; print_r($array); echo "</pre>"; } }

« previous php.notes (#89781) next »