例如,我想将字符串There are 4,000 bugs, fix them!
替换为There are 4000 bugs, fix them!
。如何删除数字之间的逗号而不是PHP中的字母
注意第一个逗号被删除,但第二个逗号被保留。
例如,我想将字符串There are 4,000 bugs, fix them!
替换为There are 4000 bugs, fix them!
。如何删除数字之间的逗号而不是PHP中的字母
注意第一个逗号被删除,但第二个逗号被保留。
preg_replace('/([0-9]),([0-9])/', '\\1\\2', 'There are 4,000 bugs, fix them!');
试试这个
$str = "There are 4,000 bugs, fix them!";
$a = preg_replace('#(?<=\d),(?=\d)#', '', $str);
print_r($a);
我想谷歌在PHP字符串解析功能你会发现许多方法来做到这一点。正则表达式是最好的,但可能会很棘手的学习。还有其他方法取决于你在做什么。 – rncrtr 2013-05-08 05:46:41