switch($arr[''])取什么值,结果3个case都计算
switch($arr[''])取什么值,结果3个case都计算,哪里错了吗?
<?php
//从数组变量$arr中,读取键为0的值
$arr = array('苹果','香蕉','雪梨'); //水果品种
$price =array('5','2.5','3');//水果单价
$count ="2";//水果斤数
switch($arr['2'])
{
case 0 ://购买苹果
$totalmoney = $count * $price[0];
echo "购买苹果".$count."斤,共".$totalmoney."元钱";
case 1 ://购买香蕉
$totalmoney = $count * $price[1];
echo "购买香蕉".$count."斤,共".$totalmoney."元钱";
case 2 ://购买雪梨
$totalmoney = $count * $price[2];
echo "购买雪梨".$count."斤,共".$totalmoney."元钱";
}
?>