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

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

WBOY
WBOYOriginal
2016-06-13 09:35:071263browse

获得表单请求的值:

案例:

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)//四舍五入的方法
?>
Statement:
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