This what your looking for?
$_POST['names'] = ' Arthur Ignatius Conan Doyle ';
$names = trim(preg_replace('/\s+/', ' ', $_POST['names']));
$parts = explode(' ',$names , 3);
list($firstNamm, $surName, $familyName) = array_replace(array_fill(0,3,''), $parts );
Explanation,
preg_replace('/\s+/', ' ', $_POST['names']) is used to reduce multiple spaces down to a single whitespace.
from
' Arthur Ignatius Conan Doyle '
to
' Arthur Ignatius Conan Doyle '
trim() is used to remove whitespace from the beginning and end of a string, you can provide a second argument if you wish to remove other characters.
which now gives us
'Arthur Ignatius Conan Doyle'
explode() splits a string into an array when given a delimiter (" "), the 3rd arguments let you set the maximum number of parts to split the string into.
as the string may not have 3 parts its possible that an empty array is returned.
array_fill(0,3,'') creates an array with three elements all set to an empty string.
array_replace(array_fill(0,3,''), $parts ); returns the array but with values replaced with any values provided by the $parts array.
This array is passed to the list construct which populates a list of variables with the values of each array element.