3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function str_replace_word($needle,$replacement,$haystack){ $pattern = "/\b$needle\b/i"; $haystack = preg_replace($pattern, $replacement, $haystack); return $haystack; } $str = "ann@ibbeck.de,Petermann@ibbeck.de"; echo $str = str_replace_word('ann@ibbeck.de','kan',"ann@ibbeck.de,Petermann@ibbeck.de"); echo $str = str_replace_word('Petermann@ibbeck.de','AP',$str); ?>
Output for 4.3.0 - 7.1.0, 7.1.6 - 7.2.0
kan,Petermann@ibbeck.dekan,AP
Output for 7.1.5

Process exited with code 137.