note 56922 deleted from function.mysql-fetch-row by mazzanet
| From: | mazzanet@php.net | Date: | Mon, 19 Sep 2005 20:55:12 +0000 |
| Subject: | note 56922 deleted from function.mysql-fetch-row by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-95433@lists.php.net to get a copy of this message | ||
Note Submitter: ahigerd at stratitec dot com
----
The function in the previous comment is a little bit inefficient. There's no need for tracking
an index variable or calling mysql_num_rows after every iteration. Try this:
<?php
function mysql_fetch_all($result) {
for($row = mysql_fetch_array($result);
$row;
$row = mysql_fetch_array($result)) {
$return[] = $row;
}
return $return;
}
?>
This produces the same output as the previous function.