3v4l.org

run code in 300+ PHP versions simultaneously
<?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 = false; $repu = preg_replace_callback(array_map(function($w) { return '/\b' . preg_quote($w, '/') . '\b/i'; }, $badwords), function($match) use ($replaceChar) { $match_found = true; return str_repeat($replaceChar, strlen($match[0])); }, $text ); return array('error' =>$match_found, 'text' => $repu ); }
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [error] => [text] => This is a ***. . Grass. is good but *** is bad. )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
54.79 ms | 401 KiB | 8 Q