现在数据库里面有一堆数据
1,2,3,
2,4,1,11,
111,1,31,
3,11,
我想要的效果是把1,去掉 下面用到了正则匹配
#先通过sql语句把带1,的查找出来
#在通过foreach循环处理
$tab = M('tab')->where('aid like "%1,%" or aid like "%,1,%"')->select();
foreach($tab as $k=>$v){
$aid = preg_replace("/,1,/",",",$tab[$k]['aid']);
$aid = preg_replace("/^1,/","",$aid);
echo $aid;
}
END