php 转义符

$array = array('test','测试','test1','test2');

echo "'".implode("','", $array )."'";//以单引号+逗号+单引号 隔开,同时两边也加上一个单引号

//结果: 'test','测试','test1','test2'
这可以用在数据库的where in条件中
如"where name in ( '".implode("','",  $array  )."' )";
 
参考链接: http://isblog.blog.163.com/blog/static/72416752013211162583/

猜你喜欢

转载自wandejun1012.iteye.com/blog/2302735