August 30, 2013, 6:47 pm
/** split a name into the first name and last name
* @param input The name eg 'John Doe'
* @return Array containing firstname and lastname eg array('firstname'=>'John', 'lastname'=>'Doe');
*/
function splitname($input)
{
$output = array("firstname"=>"", "lastname"=>"");
$space = strpos($input, " ");
if ($space !== false)
{
$output['firstname'] = substr($input, 0, $space);
$output['lastname'] = substr($input, $space, strlen($input));
}
else
{
$output['lastname'] = $input;
}
return $output;
}