php獲取從html表單傳遞數(shù)組的方法
更新時間:2015年03月20日 08:56:11 作者:work24
這篇文章主要介紹了php獲取從html表單傳遞數(shù)組的方法,實例分析了php操作表單元素的技巧,非常具有實用價值,需要的朋友可以參考下
本文實例講述了php獲取從html表單傳遞數(shù)組的方法。分享給大家供大家參考。具體如下:
將表單的各個元素的name都設置成同一個數(shù)組對象既可以以數(shù)組的方式傳遞表單值
html頁面如下:
<form method="post" action="arrayformdata.php"> <label>Tags</label> <input type="text" name="tags[]"/> <input type="text" name="tags[]"/> <input type="text" name="tags[]"/> <input type="text" name="tags[]"/> <input type="text" name="tags[]"/> <input type="submit" value="submit"> </form> </html>
arrayformdata.php頁面如下:
<?php $postedtags = $_POST['tags']; foreach ($postedtags as $tag){ echo "<br />$tag"; } ?>
希望本文所述對大家的php程序設計有所幫助。
相關文章
phpQuery采集網(wǎng)頁實現(xiàn)代碼實例
這篇文章主要介紹了phpQuery采集網(wǎng)頁實現(xiàn)代碼實例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下2020-04-04