1
我将如何最好地实现以下内容:如何仅替换字符串的未加引号的部分?
我想在PHP中找到并替换字符串中的值,除非它们使用单引号或双引号。
EG。
$string = 'The quoted words I would like to replace unless they are "part of a quoted string" ';
$terms = array(
'quoted' => 'replaced'
);
$find = array_keys($terms);
$replace = array_values($terms);
$content = str_replace($find, $replace, $string);
echo $string;
echo
“d字符串应该返回:
'The replaced words I would like to replace unless they are "part of a quoted string" '
在此先感谢您的帮助。
谢谢,工作起来就像一个魅力。非常感谢赞助:) – Chris 2010-11-17 22:11:29