3v4l.org

run code in 300+ PHP versions simultaneously
<?php $patterns = ['/\bhim\b/', '/\bhimself\b/', '/\bhe\b/', '/\bhis\b/']; $replacements = ['her', 'herself', 'she', 'her']; $str = 'he went by "himself" (his imaginary friend came with him) to the himalayas. this was not the first time in history '; echo preg_replace($patterns, $replacements, $str);

preferences:
49.96 ms | 402 KiB | 5 Q