$price = array(
'value' => 40,
'mo_desc' => array(
'monthly' => 1,
'quartely' => 0.95,
'semi-anualy' => 0.90,
'anualy' => 0.85,
'bi-anualy' => 0.75
),
'plan_desc' => array(
'one' => 1,
'two' => 1.9,
'tree' => 3.6,
'four' => 6.8,
'five' => 9.6,
'six' => 12,
'seven' => 16.8,
'eight' => 20.8
)
);
我需要得到变量组合。
$price_monthly_plan_one = $price['value'] * $price['mo_desc']['monthly'] * $price['plan_desc']['one'];
$price_quartely_plan_one = $price['value'] * $price['mo_desc']['quartely'] * $price['plan_desc']['one'];
$price_quartely_plan_two = $price['value'] * $price['mo_desc']['quartely'] * $price['plan_desc']['two'];
...我用 for、while 和 foreach 做了很多尝试。我不能那样做。如果有人可以帮忙!
我正在尝试执行一个函数,我将发送 $price 并且该函数将返回如下价格:
$price = array(
'plan_1' => array ('price_monthly' => 40,'price_quartely' => xx,'price_semi-anualy' => xx,'price_anualy' => xx,'price_bianualy' => xx),
'plan_2' => array ('price_monthly' => 40,'price_quartely' => xx,'price_semi-anualy' => xx,'price_anualy' => xx,'price_bianualy' => xx),
'plan_3' => array ('price_monthly' => 40,'price_quartely' => xx,'price_semi-anualy' => xx,'price_anualy' => xx,'price_bianualy' => xx),
'plan_4' => array ('price_monthly' => 40,'price_quartely' => xx,'price_semi-anualy' => xx,'price_anualy' => xx,'price_bianualy' => xx),
'plan_5' => array ('price_monthly' => 40,'price_quartely' => xx,'price_semi-anualy' => xx,'price_anualy' => xx,'price_bianualy' => xx),
'plan_6' => array ('price_monthly' => 40,'price_quartely' => xx,'price_semi-anualy' => xx,'price_anualy' => xx,'price_bianualy' => xx),
'plan_7' => array ('price_monthly' => 40,'price_quartely' => xx,'price_semi-anualy' => xx,'price_anualy' => xx,'price_bianualy' => xx),
'plan_8' => array ('price_monthly' => 40,'price_quartely' => xx,'price_semi-anualy' => xx,'price_anualy' => xx,'price_bianualy' => xx)
);
难……非常难……尝试了8个多小时!