3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $str = <<<STR one blah two blah foo blah three blah foo blah four blah five blah foo blah STR; $regex = '~^foo.*$~m'; echo preg_replace($regex, '', $str, -1, $count), "\n"; echo "$count\n";
Output for 5.1.3 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
one blah two blah three blah four blah five blah 3
Output for 5.1.2
Notice: Undefined variable: count in /in/FQf5U on line 17 one blah two blah three blah four blah five blah Notice: Undefined variable: count in /in/FQf5U on line 18
Output for 5.1.0 - 5.1.1
Notice: Undefined variable: count in /in/FQf5U on line 16 one blah two blah three blah four blah five blah Notice: Undefined variable: count in /in/FQf5U on line 17
Output for 5.0.4 - 5.0.5
Notice: Undefined variable: count in /in/FQf5U on line 16 Warning: Wrong parameter count for preg_replace() in /in/FQf5U on line 16 Notice: Undefined variable: count in /in/FQf5U on line 17
Output for 4.3.0 - 4.4.1, 4.4.3 - 5.0.3
Notice: Undefined variable: count in /in/FQf5U on line 16 Warning: Wrong parameter count for preg_replace() in /in/FQf5U on line 16 Notice: Undefined variable: count in /in/FQf5U on line 17
Output for 4.4.2
Notice: Undefined variable: count in /in/FQf5U on line 17 Warning: Wrong parameter count for preg_replace() in /in/FQf5U on line 17 Notice: Undefined variable: count in /in/FQf5U on line 18