note 99985 deleted from function.mysql-fetch-array by danbrown
| From: | danbrown@php.net | Date: | Fri, 17 Sep 2010 21:15:47 +0000 |
| Subject: | note 99985 deleted from function.mysql-fetch-array by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-172705@lists.php.net to get a copy of this message | ||
Note Submitter: naomi
----
Inspired by KingIsulgard, here is a real one-liner for transforming a resultset into an array of
arrays:
<?
for($i = 0; $i < mysql_num_rows( $result ) && $arr[$i] = mysql_fetch_assoc($result);
$i++) ;
?>
And here's a two-liner, but a shorter one:
<?
while ( $arr[] = mysql_fetch_assoc( $result ) ) ;
array_pop( $arr );
?>
I wonder if there's a solution out there that avoids either inelegance ?