php簡單獲取復(fù)選框值的方法

字號:


    這篇文章主要介紹了php簡單獲取復(fù)選框值的方法,簡單分析了php以數(shù)組形式傳遞復(fù)選框checkbox值的實(shí)現(xiàn)方法,需要的朋友可以參考下
    html:
    <form id="form1" name="form1" method="post" action="checkbox.php">
    <input type=checkbox name=checkbox[] value="1">
    <input type=checkbox name=checkbox[] value="2">
    <input type=checkbox name=checkbox[] value="3">
    <input type=checkbox name=checkbox[] value="4">
    <input type=checkbox name=checkbox[] value="5">
    <input type="submit" name="button" id="checkbox" value="提交" />
    </form>
    php:
    <?php
    $text1=$_POST['checkbox'];
    for($i=0;$i<count($text1);$i++)
    {
    $yourwant = $text1[$i]; 
    echo $yourwant."<br/>";
    }
    ?>
    希望本文所述對大家PHP程序設(shè)計(jì)有所幫助。