3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = ["White", "White Tank", "White Tank Top"]; foreach ($strings as $string) { echo "\n{$string}:"; echo "\n-\t" , substr($string, 1 + (strpos($string, ' ') ?: -1)); $explodeOnce = explode(' ', $string, 2); echo "\n-\t" , end($explodeOnce); echo "\n-\t" , substr(strstr($string, " "), 1); echo "\n-\t" , ltrim(strstr($string, " ")); echo "\n-\t" , preg_replace('~^\S+\s~', '', $string); }
Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14
White: - White - White - - - White White Tank: - Tank - Tank - Tank - Tank - Tank White Tank Top: - Tank Top - Tank Top - Tank Top - Tank Top - Tank Top

preferences:
152.48 ms | 408 KiB | 5 Q