Q:

generate multi-dimentional array from PHP/MySQL

I would like to obtain the same result mith my mysql table. Below my table:
CREATE TABLE IF NOT EXISTS `map_point` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Location` varchar(80) NOT NULL,
  `type` varchar(80) NOT NULL,
  `icon` varchar(70) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=898 ;

type are Phase1, Phase2...... The final multi-dimentional array must show like this:
$data = array ( "Phase1" => array("name"=>"Phase 1", "icon"=>"icons/iconb.png"),
                "Phase2" => array("name"=>"Phase 2", "icon"=>"icons/icong.png"),
                "Phase3" => array("name"=>"Phase 3", "icon"=>"icons/iconr.png"),
                "Phase2p" => array("name"=>"Phase 2+", "icon"=>"icons/icony.png"),
                "Phase3p" => array("name"=>"Phase 3+", "icon"=>"icons/iconpi.png"),
                "RollOut2012" => array("name"=>"Roll Out 2012","icon"=>"icons/iconor.png"),
                "RollOut120sites" => array("name"=>"Roll Out 120 Sites", "icon"=>"icons/iconma.png"),                   
);

Thank you in advance for your help.

A:

You can try something of the sort
$jsondata = array();
$result = mysql_query("SELECT type AS name, icon FROM map_point");
while($row = mysql_fetch_assoc($result)) { 
  if(!array_key_exists($row['type'], $jsondata))
    $jsondata[$row['name']] = $row
  else
    array_push($jsondata[$row['name']] , $row)
}

