The following will give you everything up to the first space:
$name = "John Smith";
$name = substr($name, 0, strpos($name, ' '));
echo $name; //John
You could also use the explode function to get an array of all the words in the string:
$name = "John Smith";
$words = explode(' ', $name);
echo $words[0]; //John
echo $words[1]; //Smith