Qyouu
你可以使用preg_replace这个正则表达式,它看起来对=未通过前面的迹象<,>,!或=或之后=:(?<![<>=!])=(?!=)例如:$string = "I need to replace = in string with == sign, but not in <=, != and >= signs.";
echo preg_replace('/(?<![<>=!])=(?!=)/', '==', $string);输出:I need to replace == in string with == sign, but not in <=, != and >= signs.3v4l.org 上的演示