我将如何最好地实现以下目标:
我想在 PHP 中查找和替换字符串中的值,除非它们是单引号或双引号。
例如。
$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" '
在此先感谢您的帮助。