Heim >Backend-Entwicklung >PHP-Tutorial >加入单引号
数组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."'";
}
}