Re: Array Push question
| From: | Richard Lynch | Date: | Fri, 13 Jul 2007 07:02:33 +0000 |
| Subject: | Re: Array Push question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-258765@lists.php.net to get a copy of this message | ||
On Thu, July 12, 2007 3:45 am, John Comerford wrote:
> Is there a better way of doing the following:
>
> $Rows[] = array();
> $currentRow = count($Rows) - 1;
> $Rows[$currentRow]['test'] = "this is a test";
>
> Specifically I am wonder if I can avoid having to use 'count'.
count() is not slow, really...
PHP maintains the count internally as you add stuff, so it is a quick
lookup.
Or you could just do:
$Rows[] = array('test'=>"this is a test");
At least I think that works out the same array-wise...
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?