3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Name { public static function split($name) { return (object) [ 'forename' => strtok($name, ' '), 'surname' => substr($name, (strpos($name, ' ') ?: -1) + 1) ]; } } echo Name::split('Daniel Michael Griffiths')->surname;

preferences:
56.16 ms | 402 KiB | 5 Q