Blogger Information
Blog 9
fans 0
comment 0
visits 5088
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
计算不定参数的乘积-2019-09-28
睡在键盘上
Original
469 people have browsed it

实例

/*
 * 计算多个数字相乘
 * $param1 : 参数1
 * $param2 : 参数2
 * $param3 : 参数3,多个数字的数组集合
 * */
function calculate($param1,$param2,...$param3){

    //第一步:先将$param1,$param2加入到集合中
    array_unshift($param3,$param1);
    array_unshift($param3,$param2);

    //第二步:循环数组取数组,然后计算
    $result = 1;
    foreach ($param3 as $value){
        $result *= $value;
    }

    return $result;
}

echo calculate(2,3,4,5);
exit();

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:unqualified

Teacher's comments:看一下群公告中的作业要求
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post