您好,登錄后才能下訂單哦!
php輸入幾個數(shù)從大到小排序的案例?這個問題可能是我們?nèi)粘W習或工作經(jīng)常見到的。希望通過這個問題能讓你收獲頗深。下面是小編給大家?guī)淼膮⒖純?nèi)容,讓我們一起來看看吧!
php輸入幾個數(shù)從大到小排序
以下程序?qū)崿F(xiàn)了在網(wǎng)頁輸入幾個數(shù),按照從大到小排序并輸出的功能,希望對需要的朋友有幫助:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <p>請輸入要排序的數(shù)據(jù)</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> <?php if(isset($_POST['button'])){ echo "排序后的數(shù)據(jù)如下所示:"; echo '<br/>'; $array=array( "0"=>$_POST['textfield'], "1"=>$_POST['textfield2'], "2"=>$_POST['textfield3'], "3"=>$_POST['textfield4'], "4"=>$_POST['textfield5'],);//把數(shù)字存到數(shù)組中 rsort($array); foreach($array as $key => $value){ echo $value;//循環(huán)輸出值 echo '<br/>'; } } ?>
感謝各位的閱讀!看完上述內(nèi)容,你們對php輸入幾個數(shù)從大到小排序的案例大概了解了嗎?希望文章內(nèi)容對大家有所幫助。如果想了解更多相關(guān)文章內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊頻道。
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。