PHP的破灭(101)报价 [英] php implode (101) with quotes

查看:111
本文介绍了PHP的破灭(101)报价的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

爆一个简单的数组

看起来像这样

$array = array('lastname', 'email', 'phone');
$comma_separated = implode(",", $array);

这将返回该

 lastname,email,phone

很大,所以我可能做到这一点,而不是

great, so i might do this instead

$array = array('lastname', 'email', 'phone');
$comma_separated = implode("','", $array);
$comma_separated = "'".$comma_separated."'";

和现在我有什么,我希望有一个不错的pretty CSV字符串

and now i have what I want a nice pretty csv string

 'lastname','email','phone'

有没有更好的方式来做到这一点,那感觉对我来说,应该有破灭我失去的东西吗?一个可选的参数

is there a better way to do this, it feels to me like there should be an optional parameter for implode am I missing something ?

推荐答案

没有,你正在做的方式是就好了。 破灭()只需要1-2个参数(如果你只是提供一个数组,它由一个空字符串加入件)。

No, the way that you're doing it is just fine. implode() only takes 1-2 parameters (if you just supply an array, it joins the pieces by an empty string).

这篇关于PHP的破灭(101)报价的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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