Re: Array Push question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux