proud Posted June 22, 2009 Share Posted June 22, 2009 $full_name="Mike Jerry Hanson"; I want to split this full name into 3 parts and assign each to a different variable Example: $first_name="Mike"; $mid_name="Jerry"; $last_name="Hanson"; Note that I don't know the $full_name string length, the only thing that separates first name, middle name and last name is the space between them. To elaborate: $full_name=$first_name." ".$mid_name." ".$last_name; Quote Link to comment Share on other sites More sharing options...
joel24 Posted June 22, 2009 Share Posted June 22, 2009 $full_name="Mike Jerry Hanson"; $fullname = explode(" ", $fullname); which splits $fullname into an array, split up by the spaces. so $fullname[0] is now "Mike" $fullname[1] is now "Jerry" $fullname[2] is now "Hanson" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.