Re: Array Push question

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

 



On Thu, 12 Jul 2007 18:45:36 +1000, John Comerford <johnc@xxxxxxxxxxxxxxxxxxxx> wrote:
> Hi Folks,
> 
> 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'.
> 
> TIA,
>   JC
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

This code looks weird...

$currenRow will be numeric. So why would you do $currentRow['test']?
Anyway if you just wanna add an element to the end of the array use array_push

http://nl3.php.net/manual/en/function.array-push.php

-- 
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