Anyways, I'm trying to check if a "custom regex" (something inside parentheses) is the same as another.
For example
Code: Select all
$text = "Hello World and Hi Neighbor";
$match = array('@([Hello|Hi]) World and ([Hello|Hi]) Neighbor@');
$replace = array('\1 World and Neighbor');
echo preg_replace($match, $replace, $text);However, I don't want it to echo that, since the text had both "Hello" and "Hi".
How can I echo the preg_replace only if \1 is the same as \2?