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

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

WBOY
Release: 2016-06-23 13:07:37
Original
1437 people have browsed it

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

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


回复讨论(解决方案)

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

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

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template