当前位置:Gxlcms > PHP教程 > 加入单引号

加入单引号

时间:2021-07-01 10:21:17 帮助过:16人阅读

本帖最后由 lazygc520 于 2013-08-27 11:37:36 编辑

数组a:
array (  0 =>   array (    0 => 'CVT121015001',  ),  1 =>   array (    0 => 'CVT121015002',    1 => 'CVT121226001',  ),$val_3 = implode(",",$a[$k]);echo $val_3;//得到:CVT121015001CVT121015002,CVT121226001//如何让得到的值变成:‘CVT121015001’‘CVT121015002’,‘CVT121226001’


回复讨论(解决方案)

或者已知$val_3:

CVT121015001
CVT121015002,CVT121226001

将其带入查询语句:
$sql = "select lotno,count(lotno) as count from `table` where packageno in (.$value.) group by lotno order by lotno asc";

请问如何处理?

$val_3 = "'" . implode("','",$a[$k]) . "'";

$val_3 = implode(",",$a[$k]);
$res = '';
foreach($val_3 as $val){
if(empty($res)){
$res .= "'".$val."'";
}else{
$res .= ",'".$val."'";
}
}

人气教程排行