At 00:14 29.08.2003, Mike Morton said: --------------------[snip]-------------------- > >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. --------------------[snip]--------------------
Mike, the solution is quite simple, and is already buried in some of the responses until now. Modifying your sample code, this will work and generate your expected results: $transactions=Array(); While($row=mysql_fetch_array($res) { // array_push($transactions,$row[dealercode]=>Array()); $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[amount]; $transactions[$row['dealercount']][$morerows['country']] = $morerows['amount']; } } Hope this helps, -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php