如何使用正确的开关或条件语句?

How to use proper switch or condition statement?

你能帮我解决这个问题吗:

为此

$share Value <= 30000 the term is from 1 - 36 with 1.3% on the first term and diminishing value of .65 on the next term while $share Value >= 30001 with diminishing value of .75

    <?php
// Create a function that can accept parameters
function CalculateItem($share = 0,$terms = 0)
    {
        if($share <= 30000)
            $multiplier =   ($terms == "1")? .0130 : .0195;
        elseif($share >= 30001)
            $multiplier =   ($terms == "1")? .0130 : .0205;

        if(empty($multiplier))
            return;

        $data['share']              =   $share;
        $data['terms']              =   $terms; 
        $data['interest']           =   ($share * $multiplier);                     
        $data['service_fee']        =   ($share * .01);
        $data['filling_fee']        =   30;
        $data['cash_on_hand']       =   $share - ($data['service_fee'] + $data['interest'] + $data['filling_fee']);
        $data['loan_receivable']    =   $data['cash_on_hand'] + $data['service_fee'] + $data['interest'] + $data['filling_fee'];
        $data['debit']              =   $data['loan_receivable'];
        $data['credit']             =   $data['interest'] + $data['service_fee'] + $data['filling_fee'] + $data['cash_on_hand'];

        return $data;
    }

// Get the state of data. Anything but false will trigger the breakout table
$data   =   (isset($_POST['calculate']))? CalculateItem($_POST['share'],$_POST['terms']) : false;
?>

虽然费率是固定的,但您可以按照 --

$rate=.0130;
 if($share <= 30000)
            $multiplier =   $rate + ($terms-1)*(0.65);
        elseif($share >= 30001)
            $multiplier =   $rate + ($terms-1)*(0.75);

通过这种方式,您可以根据所有条款进行计算