3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "Each person wants peaches for themselves forever"; $blacklist = array("for", "each"); //print_r($blacklist); // if you might have non-letter characters that have special meaning to the regex engine //$blacklist = array_map(function($v){return preg_quote($v, '/');}, $blacklist); //print_r($blacklist); echo "Without wordboundaries:\n"; var_export(preg_replace('/' . implode('|', $blacklist) . '/i', '', $string)); echo "\n\n---\n"; echo "With wordboundaries:\n"; var_export(preg_replace('/\b(?:' . implode('|', $blacklist) . ')\b/i', '', $string)); echo "\n\n---\n"; echo "With wordboundaries and consecutive space mop up:\n"; var_export(trim(preg_replace(array('/\b(?:' . implode('|', $blacklist) . ')\b/i', '/ \K +/'), '', $string)));
Output for git.master, git.master_jit, rfc.property-hooks
Without wordboundaries: ' person wants pes themselves ever' --- With wordboundaries: ' person wants peaches themselves forever' --- With wordboundaries and consecutive space mop up: 'person wants peaches themselves forever'

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