2007. 07. 12, csütörtök keltezéssel 10.28-kor Stut ezt írta: > John Comerford 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'. > > 1) The code above will produce a $currentRow of -1 which is probably not > what you want. 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. greets Zoltán Németh > > 2) If you actually mean that you have an array that contains items and > you want the last one, used end (http://php.net/end). > > 3) I'm not really sure what the context is, but this is a very odd way > of working with arrays. Either you already know the key or you don't. If > you're just trying to append to the array you can do that with the > following syntax... $Rows[] = array('test' => 'this is a test'); > > -Stut > > -- > http://stut.net/ > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php