note 38664 deleted from function.mysql-fetch-array by nlopess
| From: | nlopess@php.net | Date: | Fri, 02 Jan 2004 11:43:10 +0000 |
| Subject: | note 38664 deleted from function.mysql-fetch-array by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-62776@lists.php.net to get a copy of this message | ||
Note Submitter: philium@philium.org
----
I got tired of needing to do this so often, so I wrote a function to do it for me:
<?php
function resource2array($resource)
{
$num_rows = mysql_num_rows($resource);
$j = 0;
for($i=1; $i <= $num_rows; $i++)
{
$result[$j] = mysql_fetch_array($resource, MYSQL_ASSOC);
$j++;
}
return $result;
mysql_free_result($result);
}
?>
It really made things a lot easier.
Philip Ridgeway
http://www.philium.org