3v4l.org

run code in 300+ PHP versions simultaneously
<?php $orig = 'welcome-to-your-world-42'; //$orig = 'welcome'; $parts = explode('-', $orig); if (1 < count($parts)) { usort($parts, function($a, $b) { return strlen($a) < strlen($b); }); $s1 = array_shift($parts); $s2 = array_shift($parts); } else { $s1 = $s2 = $orig; } echo $s1 . PHP_EOL . $s2;
based on B81H2
Output for 8.0.0alpha2
Deprecated: usort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in /in/7IQEP on line 7 welcome world
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.31, 7.3.0 - 7.3.19, 7.4.0 - 7.4.7, 8.0.0alpha1
welcome world