Home > php教程 > php手册 > php表单请求获得数据求和示例

php表单请求获得数据求和示例

WBOY
Release: 2016-06-13 09:35:07
Original
1292 people have browsed it

获得表单请求的值:

案例:

request.php

复制代码 代码如下:





计算请求









[code]
result.php
[code]
$grade=$_REQUEST['grade'];//grade-->和表单中的name值一样
$arr=explode(" ",$grade);//以空格拆分字符串,并得到数组结果
print_r($arr);
$res=0;
for($i=0;$i$res+=$arr[$i];
}
echo "
ALL=".$res;
echo "
AVG=".(round($res/count($arr),0));//round(12.334,2)//四舍五入的方法
?>
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template