Page 1 of 1

disecting a string

Posted: Sat May 12, 2007 2:15 pm
by aceconcepts
Hi,

I have a contact form with a name field.

In this name field the user will enter there full name i.e. "Bill Smith"

My question is: how can I split up this string so that I can insert both the first and last name into seperate fields in a database?

Thanks.

Posted: Sat May 12, 2007 2:38 pm
by jayshields

Code: Select all

$names = explode(" ", $_POST['name']);
$first_name = $names[0];
$last_name = $names[1];

Posted: Sat May 12, 2007 6:15 pm
by aceconcepts
Thanks for the response.

Cheers