Re: Array Push question
| From: | Stut | Date: | Thu, 12 Jul 2007 12:10:50 +0000 |
| Subject: | Re: Array Push question | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-258684@lists.php.net to get a copy of this message | ||
M. Sokolewicz wrote:
Stut wrote:Nothing, unless you're building a complex element. I was assuming that the OP had simplified their code down to the minimum required to illustrate the problem. -Stut -- http://stut.net/Zoltán Németh wrote:what's wrong with skipping the temporary variable and just doing $Rows[] = array('test'=>'this is a test'); ?2007. 07. 12, csütörtök keltezéssel 10.28-kor Stut ezt írta:Indeed, my bad. In that case the OP is better off creating the item in a temporary variable and then adding it to the array. $row = array(); $row['test'] = 'this is a test'; $Rows[] = $row; -StutJohn Comerford wrote:Maybe you didn't notice the [] in the first line of the OP's code? I think this code should produce 0 for $currentRow, not -1.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'.1) The code above will produce a $currentRow of -1 which is probably not what you want.