字符串与数组转换,循环输出

后端开发   发布日期:2023年05月06日   浏览次数:241

以数组形式提交的表单,获取数组元素并组合成字符串

if ($post!='') {
    $post_str = ','.implode(",",$post).',';//两端带半角逗号,形式闭环字符串
}

将字符串转为数组并循环转出:

$keyword_array=explode(',',$keyword);
$keyword_str='';

for ($b=0;$b<count($keyword_array);$b++){
	$sql="select * from abc where id='".$keyword_array[$b]."' order by px";
	$result=$mysqli->query($sql);
	while ($rs=$result->fetch_assoc()){
		$keyword_str.=$rs["keyword"].",";
	}
}


以上就是字符串与数组转换,循环输出的详细内容,更多关于字符串与数组转换,循环输出的资料请关注九品源码其它相关文章!