php 逗号 explode分割字符串 或 implode组装成字符串
php 逗号 分割字符串
介绍两个函数给你 
<?php 
//利用 explode 函数分割字符串到数组 
$source = "hello1,hello2,hello3,hello4,hello5";//按逗号分离字符串 
$hello = explode(',',$source); 
for($index=0;$index<count($hello);$index++){ 
echo $hello[$index];echo "</br>"; 
} 
?> 
<?php 
//split函数进行字符分割 
// 分隔符可以是斜线,点,或横线 
$date = "04/30/1973"; 
list($month, $day, $year) = split ('[/.-]', $date); 
echo "Month: $month; Day: $day; Year: $year<br />\n"; 
?>
组装成字符串:
  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语句执行。
 
                    
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号