Split a name with PHP

I was recently looking for a way to clean up the sign up form for a project I’m working on. I realised I could merge the First name and Last name fields on the form but I needed a way to split the name up afterwards. So after a quick “Google” I came up with a way. The code below splits the name at the first space.

Input: John S Smith
Output: First Name: John Last Name: S Smith

// PHP

$name = "John S Smith";

list($fname, $lname) = split(' ', $name,2);

echo "First Name: $fname, Last Name: $lname";