Home >Backend Development >PHP Tutorial >如何把数组变成带单引号的字符串?

如何把数组变成带单引号的字符串?

WBOY
WBOYOriginal
2016-06-23 13:07:371439browse

$a = array(2,3,4);

数组$a如何 转变为结果为‘2’,‘3’,‘4’ 的字符串,   谢谢!


回复讨论(解决方案)

$a = array(2,3,4);foreach($a as &$v) $v = "'$v'";print_r($a);

$a = array(2,3,4);$s = "'" . join("','", $a) . "'";echo $s;
'2','3','4'

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