Re: Nested Arrays
| From: | Marek Kilimajer | Date: | Fri, 27 Dec 2002 16:41:27 +0000 |
| Subject: | Re: Nested Arrays | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-129454@lists.php.net to get a copy of this message | ||
while($tmp=mysql_fetch_array($res)) { // now $tmp is now an array (as the function name suggests)
$rows[]=$tmp; // by assigning to $rows[], we make $rows an array, adding array $tmp as the last element
}
and this makes it multidimensional
Beauford.2002 wrote:
Great. now can you explain why this works. I'm confused at how PHP knows this is a multidimensional array. I was trying something like $tmp[][]=???. TIA ----- Original Message ----- From: "Marek Kilimajer" <kilimajer@webglobe.sk> Cc: "Beauford.2002" <beauford.2002@rogers.com>; "PHP General" <php-general@lists.php.net> Sent: Friday, December 27, 2002 8:45 AM Subject: Re: [PHP] Nested ArraysSorry, now I reminded myself this would cause a false element at the end of $rows, use this: while($tmp=mysql_fetch_array($res)) { $rows[]=$tmp; } Marek Kilimajer wrote:Simple: while($rows[]=mysql_fetch_array($res)) {} ($res is a mysql result resource)