3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $badwords = array('dog', 'dala', 'bad3', 'ass'); $text = 'This is a dog. . Grass. is good but ass is bad.'; print_r( filterBadwords($text,$badwords)); function filterBadwords($text, array $badwords, $replaceChar = '*') { //$match_found = 0; $repu = preg_replace_callback(array_map(function($w) { return '/\b' . preg_quote($w, '/') . '\b/i'; }, $badwords), function($match) use ($replaceChar) { $match_found = 1; return str_repeat($replaceChar, strlen($match[0])); }, $text ); if(stricmp($repu,$text) === 0) echo "ok"; else echo "not ok"; return array('error' =>$match_found, 'text' => $repu ); }
based on QoAAH
Output for 7.0.0 - 7.3.0rc2
Fatal error: Uncaught Error: Call to undefined function stricmp() in /in/MNV4I:16 Stack trace: #0 /in/MNV4I(4): filterBadwords('This is a dog. ...', Array) #1 {main} thrown in /in/MNV4I on line 16
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: Call to undefined function stricmp() in /in/MNV4I:-1 Stack trace: #0 /in/MNV4I(-1): filterBadwords() #1 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
Fatal error: Uncaught Error: Call to undefined function stricmp() in /in/MNV4I:16 Stack trace: #0 /in/MNV4I(4): filterBadwords() #1 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Fatal error: Call to undefined function stricmp() in /in/MNV4I on line 16
Process exited with code 255.