3v4l.org

run code in 300+ PHP versions simultaneously
<?php function badwords_full($string, &$bad_references) { static $bad_counter; static $bad_list; static $bad_list_q; if(!isset($bad_counter)) { $bad_counter = 0; $bad_list = badwords_list(); $bad_list_q = array_map('preg_quote', $bad_list); } return preg_replace_callback('~('.implode('|', $bad_list_q).')~', function($matches) use (&$bad_counter, &$bad_references) { $bad_counter++; $bad_references[$bad_counter] = $matches[0]; return mb_substr($matches[0], 0, 1).str_repeat('&squf;', strlen($matches[0]) - 1); }, $string); } function badwords_list() { # spanish $es = array( "gallina", "ñoño" ); # english $en = array( "chicken", "horse" ); # join all languages $list = array_merge($es, $en); usort($list, function($a,$b) { return strlen($b) < strlen($b); }); return $list; } echo badwords_full('Hola en español eres un ñoño!', $bad);
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: usort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in /in/AnPJl on line 34 Hola en español eres un ñ&squf;&squf;&squf;&squf;&squf;!

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:
30.6 ms | 406 KiB | 5 Q