我是PHP的新手,樂於學習。 我最近在完成練習時遇到了問題。 Here`s是我必須做的:將數據從數組中移到另一個數組
我需要定義,第一,一個多維數組女巫包含了生產商和某些手機的型號
EG:
$model = array(
"manufacurer" => array ("model1", "model2", ...),
"manufacurer2" => "array("model3", model4", ...),
);
下一個任務:從上面的數組$model
開始,我必須生成另一個多維數組,我們稱之爲$shop
。 它應該是這樣的:
$shop = array("model1"=>array("manufacurer"=> "manufacurer1",
"caractheristics" => array("lenght"=>...
"wide"=>...,
"weight"=>...)
),
"model2"=>array("manufacurer"=>...etc
這裏是我的代碼:
<?php
$modele = array(
"Nokia" => array ("3310", "n8", "1100"),
"Samsung" => array("Galaxy S7", "Bean", "e220"),
"Sony" => array("Xperia", "K750", "W810")
);
print_r($modele);
// it has stored my values
echo "<br>";
$magazin = array(
'$model["Nokia"][0]' => array(
'manufacturer' => '$modele[2]'
// How do I use the values from the $model array to $shop array? If i print_r($model["Nokia"][0]) it returnes 3310, witch is ok, but when I print_r($magazin) it returns: Array ([$modele["Nokia"][0]] => Array ([producator] => $modele[2]))
)
);
print_r($magazin);
?>