Created
February 19, 2015 06:51
-
-
Save amilabandara/ca90d526ac9af11ee0fe to your computer and use it in GitHub Desktop.
separate first name last name from string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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