3v4l.org

run code in 300+ PHP versions simultaneously
<?php function filter_ingredients($elements) { return implode(', ', array_filter(preg_split('/,\s*/', $elements), function ($v) { return !preg_match('/^no\b/', $v); })); } echo filter_ingredients("cheese, no tomato, no onion, mayo, no lettuce") . "\n"; echo filter_ingredients("no cheese, tomato, no onion, no&nbsp;mayo, lettuce") . "\n"; echo filter_ingredients("no cheese, no&nbsp;tomato, onion, no mayo, no lettuce") . "\n";

preferences:
25.61 ms | 407 KiB | 5 Q