How to export to an array a MySQL query with 3 lines of code
By reading a good contribution on PHP site, I discovered this method for exporting to an array a query submitted to MySQL:$result = mysql_query("SELECT * FROM table");It produces:
for($i = 0; $array[$i] = mysql_fetch_assoc($result); $i++) ;
array_pop($array); // removes last empty arrayArrayThat’s to say you’ll have
(
[0] => Array
(
[id] => 1
[user] => myuser
[pass] => mypass
... other fields
)
... and so oncount($array)records, of which every row hascount($array[0])fields.