3v4l.org

run code in 300+ PHP versions simultaneously
<?php $subject = <<<'STR' $array = ['bananna', 'cranberry', 'apple']; $fn = function ($a, $b) { if(strlen($a) > strlen($b)) { return 1; } return 0; }; usort($array, $fn); STR; $pattern = '%\'\w*\'%'; $replacement = 'Chocolate'; $newStory = preg_replace($pattern, $replacement, $subject); print($newStory);

preferences:
109.41 ms | 402 KiB | 5 Q