我有一個數組,我通過POST獲取持續時間(例如6),我想要價格。如何在數組中搜索我的密鑰的值?
$duration = $_POST['duration']; // Can be 6, 1 or 3
// Constantes pour l'abonnement
$suscribe = array(
'prices' => array(
1=>10,
3=>25,
6=>50
)
);
所以我想要得到一個PHP變量50的價格值。 謝謝。
'回聲$ suscribe ['prices'] [$ _ POST ['duration']];'(可能?) – briosheje
'$ suscribe ['prices'] [$ _ POST ['duration']]'? – MSadura
我很困惑。你學習了數組的語法,而沒有學習如何索引到一個? – Jon