Blogger Information
Blog 10
fans 0
comment 0
visits 7445
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
计算不定参数的乘积, 要求使用到剩余参数来实现-2019年10月7日19:00
i开哥的博客
Original
675 people have browsed it
function sum4($a,$b,...$c)
{
array_push($c,$a,$b);
return array_product($c);
}
echo sum4(1,2,3,4,5);

 php求和函数:

array_sum()

php求积函数:

array_product()

剩余参数:

...$c

...表示打包剩余的参数组成一个$c

Correction status:qualified

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!