3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "PHP What is PHP"; do { $result[] = $string; $string = preg_replace('/\s+\S+$/', '', $string, 1, $count); } while ($count); var_export($result);
Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
array ( 0 => 'PHP What is PHP', 1 => 'PHP What is', 2 => 'PHP What', 3 => 'PHP', )

preferences:
54.54 ms | 406 KiB | 5 Q