PHP将单引号添加到逗号分隔的列表中 [英] PHP add single quotes to comma separated list

查看:337
本文介绍了PHP将单引号添加到逗号分隔的列表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我分解数组时,我得到一个看起来像这样的列表:

When I implode my array I get a list that looks like this:

qwerty, QTPQ, FRQO

我需要添加单引号,使其看起来像:

I need to add single quotes so it looks like:

'qwerty', 'QTPQ', 'FRQO'

可以使用PHP完成吗?

Can this be done using PHP?

推荐答案

在implode()之前和之后使用'

Use ' before and after implode()

$temp = array("abc","xyz");

$result = "'" . implode ( "', '", $temp ) . "'";

echo $result; // 'abc', 'xyz'

这篇关于PHP将单引号添加到逗号分隔的列表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆