note 37737 modified in function.mysql-fetch-array by ronabop
| From: | ronabop@php.net | Date: | Tue, 25 Nov 2003 06:36:54 +0000 |
| Subject: | note 37737 modified in function.mysql-fetch-array by ronabop | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-60946@lists.php.net to get a copy of this message | ||
Often I need to store the entire result as an array, not just a single row... so I wrote this simple
function. It optionally accepts a row name to index by.
<?php
function mysql_fetch_array_r($result, $index_row = "", $fetch = MYSQL_ASSOC){
while ($row = mysql_fetch_array($result,$fetch)){
$whole_result[$row[$index_row]] = $row;
}
return $whole_result;
}
?>
--was--
I have updated my function. It now optionally accepts a row name to index by.
<?php
function mysql_fetch_array_r($result, $index_row = "", $fetch = MYSQL_ASSOC){
while ($row = mysql_fetch_array($result,$fetch)){
$whole_result[$row[$index_row]] = $row;
}
return $whole_result;
}
?>
http://www.php.net/manual/en/function.mysql-fetch-array.php