亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

php表單請(qǐng)求獲得數(shù)據(jù)求和示例

 更新時(shí)間:2014年05月15日 15:15:14   作者:  
這篇文章主要介紹了php表單請(qǐng)求獲得數(shù)據(jù)求和實(shí)現(xiàn)代碼,需要的朋友可以參考下
獲得表單請(qǐng)求的值:

案例:

request.php
復(fù)制代碼 代碼如下:

<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8;" />
<title>計(jì)算請(qǐng)求</title>
</head>
<body>
<form action="result.php" method="post">
<input type="text" name="grade"/>
<input type="submit" value="開(kāi)始計(jì)算"/>
</form>

</body>
</html>
[code]
result.php
[code]
<?php
$grade=$_REQUEST['grade'];//grade-->和表單中的name值一樣
$arr=explode(" ",$grade);//以空格拆分字符串,并得到數(shù)組結(jié)果
print_r($arr);
$res=0;
for($i=0;$i<count($arr);$i++){
$res+=$arr[$i];
}
echo "<br/>ALL=".$res;
echo "<br/>AVG=".(round($res/count($arr),0));//round(12.334,2)//四舍五入的方法
?>

相關(guān)文章

最新評(píng)論