3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'hello world good morning'; $result = []; $i = 0; while (preg_match_all("/(?=\b(\w+(?: \w+){{$i}})\b)/", $string, $m)) { array_unshift($result, $m[1]); ++$i; } var_export($result);

preferences:
56.61 ms | 410 KiB | 6 Q