- substr: documentation ( source)
- var_dump: documentation ( source)
- strpos: documentation ( source)
- strtok: documentation ( source)
<?php
function splitName($name)
{
return [
'forename' => strtok($name, ' '),
'surname' => substr($name, ($pos = strpos( $name, ' ' )) === false ? 0 : $pos + 1)
];
}
var_dump(splitName('Daniel Micheal Griffiths'));