How to do replacement only on unquoted parts of a string?
问题 How would I best achieve the following: I would like to find and replace values in a string in PHP unless they are in single or double quotes. 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 string should return: 'The replaced words I would like to replace unless they