Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

splitting name string in two

Status
Not open for further replies.

foxphpbomb

Programmer
Apr 10, 2007
29
US
If I receive a $_POST variable $_POST["name"] and want to split it in two based on the fact that the first name is separated from the last name with a space, and want to load the names into the varailes $FirstName and $LastName how would I do this?
 
Code:
list ($firstname, $surname) = explode (' ', $_POST['name']);

but this is such a blunt sword. it is better to be explicit and atomic about the information you collect. if you want first name and surname separately, then set two fields: one for each item of content.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top