我的朋友和我正在制作一个网站,根据您的兴趣编辑新闻报道.是否有简单的方法来取得复选框数据,并将数组从选定的复选框中删除?这是我们的表格
<form action="signup.PHP" method="POST"> Name: <input type="text" name="name" /> <br /> Username: <input type="text" name="username"> <br /> Password: <input type="password" name="pwd" /> <br /> Email: <input type="text" name="email" /> <br /> <p>By filling out this we will be able to find news articles that will interest you</p> <br /> Politics<input type="checkBox" name="interest[]" value="Politics" /> <br /> Entertainment<input type="checkBox" name="interest[]" value="Entertainment" /> <br /> Tech <input type="checkBox" name="interest[]" value="Tech" /> <br /> Health<input type="checkBox" name="interest[]" value="Health" /> <br /> Living<input type="checkBox" name="interest[]" value="Living" /> <br /> Travel <input type="checkBox" name="interest[]" value="Travel" /> <br /> World<input type="checkBox" name="interest[]" value="World" /> <br /> Leisure<input type="checkBox" name="interest[]" value="Leisure" /> <br /> Finance<input type="checkBox" name="interest[]" value="Finance" /> <br /> Celebrity Gossip<input type="checkBox" name="interest[]" value="Gossip" /> <br /> Movies<input type="checkBox" name="interest[]" value="Movies" /> <br /> Sports<input type="checkBox" name="interest[]" value="Sports" /> <br /> <input type="submit" value="Submit"> </form>
我们将如何使用这些数据创建一个PHP数组?
HTML标记:
原文链接:https://www.f2er.com/php/132387.html<form method="get"> <input type="checkBox" name="options[]" value="Politics"/> Politics<br/> <input type="checkBox" name="options[]" value="Movies"/> Movies<br/> <input type="checkBox" name="options[]" value="World "/> World<br/> <input type="submit" value="Go!" /> </form>
$checked = $_GET['options']; for($i=0; $i < count($checked); $i++){ echo "Selected " . $checked[$i] . "<br/>"; }