Skip to content

Instantly share code, notes, and snippets.

@amilabandara
Created February 19, 2015 06:51
Show Gist options
  • Save amilabandara/ca90d526ac9af11ee0fe to your computer and use it in GitHub Desktop.
Save amilabandara/ca90d526ac9af11ee0fe to your computer and use it in GitHub Desktop.
separate first name last name from string
$name = "aaa bbb ccc ddd";
$parts = explode(" ", $name);
$lastname = array_pop($parts);
$firstname = implode(" ", $parts);
echo "Lastname: $lastname";
echo "Firstname: $firstname";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment