Home > Backend Development > PHP Tutorial > PHP里要将一段数据里中文间的逗号换成全角的,应该如何做,100分

PHP里要将一段数据里中文间的逗号换成全角的,应该如何做,100分

WBOY
Release: 2016-06-23 13:45:54
Original
888 people have browsed it

例如

1,9,admin,你是我爱人,我是你爱人,是吗,20141109,769

把那几句中文之间的半角逗号换成全角逗号

多谢


回复讨论(解决方案)

$s = '1,9,admin,你是我爱人,我是你爱人,是吗,20141109,769';//以下任何一句都可以echo str_replace(',', ',', $s);echo strtr($s, array(',' => ','));echo join(',', explode(',', $s));
Copy after login
Copy after login

$s = '1,9,admin,你是我爱人,我是你爱人,是吗,20141109,769';//以下任何一句都可以echo str_replace(',', ',', $s);echo strtr($s, array(',' => ','));echo join(',', explode(',', $s));
Copy after login
Copy after login


那你把其他的也变了

嗯,是中文之间

$s = '1,9,admin,你是我爱人,我是你爱人,是吗,20141109,769';echo preg_replace('/([\x80-\xff]),([\x80-\xff])/', '$1,$2', $s);
Copy after login

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