Array Push and Keys

From: Date: Thu, 28 Aug 2003 22:14:39 +0000
Subject: Array Push and Keys
Groups: php.general 
Request: Send a blank email to php-general+get-161084@lists.php.net to get a copy of this message
I am trying to loop through some database results to build an array similar to: Array ( [33]=>Array ( [usa]=>52.00 [sa]=>553.00 ) ) And the problem that I am having is that array_push does not want to take keys when I am using it. My Code: $transactions=Array(); While($row=mysql_fetch_array($res) { array_push($transactions,$row[dealercode]=>Array()); $another_query=mysql_query("do another query here"); while($morerows=mysql_fetch_array($another_query)) { array_push($transactions[$row[dealercode],$morerows[country]=>$morerows[amou nt]; } } That *should* create the array above, but as I mentioned array_push does not seem to be taking the keys.... I just get a Parse error message for the line. (the first array_push) Is this is 'bug' (I hate to assume just because I cannot get it to work that it is a bug ;) ) or am I trying to do something that is better accomplished with another function? TIA. -- Cheers Mike Morton **************************************************** * * Tel: 905-465-1263 * Email: mike@webtraxx.com * **************************************************** "Indeed, it would not be an exaggeration to describe the history of the computer industry for the past decade as a massive effort to keep up with Apple." - Byte Magazine Given infinite time, 100 monkeys could type out the complete works of Shakespeare. Win 98 source code? Eight monkeys, five minutes. -- NullGrey

« previous php.general (#161084) next »