加入单引号

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 14:20:141190browse

本帖最后由 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."'";
     }
}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn