Re: Nested Arrays

From: Date: Fri, 27 Dec 2002 20:18:19 +0000
Subject: Re: Nested Arrays
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-129464@lists.php.net to get a copy of this message
OK, little bit of a brain cramp here. I wasn't clueing in that $tmp=mysql_fetch_array($res) was an array and was trying to do something again that was already there. Thanks for the help. Beauford ----- Original Message ----- From: "Marek Kilimajer" <kilimajer@webglobe.sk> To: "Beauford.2002" <beauford.2002@rogers.com> Cc: "PHP General" <php-general@lists.php.net> Sent: Friday, December 27, 2002 11:41 AM Subject: Re: [PHP] Nested Arrays > 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 Arrays > > > > > > > > > >>Sorry, 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) > >>> > >>> > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#129464) next »