php输入几个数从大到小排序
以下程序实现了在网页输入几个数,按照从大到小排序并输出的功能,希望对需要的朋友有帮助:
<!doctype html><html><head><meta charset="utf-8"><title>document</title></head><body><p>请输入要排序的数据</p><form id="form1" name="form1" method="post" action=""><input name="textfield" type="text" id="textfield" size="15" maxlength="15" />-<input name="textfield2" type="text" id="textfield2" size="15" />-<input name="textfield3" type="text" id="textfield3" size="15" />-<input name="textfield4" type="text" id="textfield4" size="15" />-<input name="textfield5" type="text" id="textfield5" size="15" /><input type="submit" name="button" id="button" value="提交" /></form></body></html><?phpif(isset($_post['button'])){echo "排序后的数据如下所示:";echo '<br/>';$array=array("0"=>$_post['textfield'],"1"=>$_post['textfield2'],"2"=>$_post['textfield3'],"3"=>$_post['textfield4'],"4"=>$_post['textfield5'],);//把数字存到数组中rsort($array);foreach($array as $key => $value){echo $value;//循环输出值echo '<br/>';}}?>
更多php相关知识,请访问!
以上就是php输入几个数从大到小排序的详细内容。