note 99985 added to function.mysql-fetch-array
| From: | naomi at osu1 dot php dot net | Date: | Fri, 17 Sep 2010 21:13:35 +0000 |
| Subject: | note 99985 added to function.mysql-fetch-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-172704@lists.php.net to get a copy of this message | ||
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 ?
----
Server IP: 69.147.83.197
Probable Submitter: 93.97.20.178
----
Manual Page -- http://www.php.net/manual/en/function.mysql-fetch-array.php
Edit -- https://master.php.net/note/edit/99985
Del: integrated -- https://master.php.net/note/delete/99985/integrated
Del: useless -- https://master.php.net/note/delete/99985/useless
Del: bad code -- https://master.php.net/note/delete/99985/bad+code
Del: spam -- https://master.php.net/note/delete/99985/spam
Del: non-english -- https://master.php.net/note/delete/99985/non-english
Del: in docs -- https://master.php.net/note/delete/99985/in+docs
Del: other reasons-- https://master.php.net/note/delete/99985
Reject -- https://master.php.net/note/reject/99985
Search -- https://master.php.net/manage/user-notes.php