3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function splitName($name) { return [ 'forename' => strtok($name, ' '), 'surname' => substr($name, ($pos = strpos( $name, ' ' )) === false ? 0 : $pos + 1) ]; } var_dump(splitName('Daniel Micheal Griffiths'));
based on 9L8vm
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.3.0beta1
array(2) { ["forename"]=> string(6) "Daniel" ["surname"]=> string(17) "Micheal Griffiths" }