使用implode()函数将数组逗号隔开连接为字符串

来源:互联网 发布:淘宝代刷兼职 编辑:程序博客网 时间:2024/06/11 21:34

checkbox提交过来一个数组,为了将数组中的值插入到SQL语句执行,需要将数组的键值使用逗号隔开:
index.html
<form action="2.php" method="post">
<input name="select[]" type="checkbox" value="1" />1
<input name="select[]" type="checkbox" value="2" />2
<input name="select[]" type="checkbox" value="3" />3
<input type="submit" value="submie" />
</form>
2.php
<?php
$array = $_POST["select"];
$select = implode(",", $array);
echo $select;
?>

  3个checkbox全都选择提交后,输出的结果为:1,2,3,可以直接插入到SQL语句执行。
原文地址 : https://www.xj123.info/6410.html

阅读全文
0 0