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

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

WBOY
WBOYOriginal
2016-06-23 13:45:54814browse

例如

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

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

多谢


回复讨论(解决方案)

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

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


那你把其他的也变了

嗯,是中文之间

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

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