0
Howdie do,在2x2多維數組中添加額外的關聯數組但是存儲密鑰
我有一個服務器類型的多維關聯數組。該數組包含值的子數組。
很容易地看到:
$servers = array('Dell R410 Dual Xeon X5650 Hexacore 2.66 GHz' => array('Model' =>$R410Model, 'Description' =>$R410Desc,'Counter' => $R410HexCoreE5650Count));
我要添加額外的服務器類型關聯數組。這是我做了什麼:
$servers[] = array('Atoms D510 1.66Ghz' => array('Model' =>$AtomModel, 'Description' =>$AtomDesc,'Counter' => $AtomCount));
$servers[] = array('Celerons 2.40Ghz' => array('Model' =>$CeleronModel, 'Description' =>$CeleronDesc,'Counter' => $CELERONCount));
它確實增加了價值,但它的指標,而不是實際的服務器類型鍵做的。
Array ([Dell R410 Dual Xeon X5650 Hexacore 2.66 GHz] => Array ([Model] => DELL R410 [Description] => Dual Xeon X5650 Hexacore 2.66 GHz [Counter] => 25)
[0] => Array ([Atoms D510 1.66Ghz] => Array ([Model] => ATOM [Description] => D510 1.66Ghz [Counter] => 1))
[1] => Array ([Celerons 2.40Ghz] => Array ([Model] => [Description] => [Counter] => 0)))
如何移動的子陣列了一個使之通過鍵,而不是指數增加了他們。因此,它看起來像這樣
Array ([Dell R410 Dual Xeon X5650 Hexacore 2.66 GHz] => Array ([Model] => DELL R410 [Description] => Dual Xeon X5650 Hexacore 2.66 GHz [Counter] => 25)
Array ([Atoms D510 1.66Ghz] => Array ([Model] => ATOM [Description] => D510 1.66Ghz [Counter] => 1))
Array ([Celerons 2.40Ghz] => Array ([Model] => [Description] => [Counter] => 0)))
'$服務器[SERVER_NAME] =陣列(在IT數據)':) – Darren 2014-10-08 00:28:09
只是指出了你想要的服務器,就像上面的評論^ – Ghost 2014-10-08 00:32:24