Well, I would suggest looking at [man]explode[/man] but I'm in an odly good mood for having been at work already an hour before I'm supposed to....
so...
//end takes the last value from an array
//explode makes an array out of a string by dividing it at the delimiter provided, in this case... ' ' (a space)
$lastname = end(explode(' ', $name));
//so this would work with a full name also like John Jacob Jingleheimer Schmit -- and return Schmit as $lastname