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; Link to comment https://forums.phpfreaks.com/topic/163186-solved-splitting-a-string-into-different-parts/ 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" Link to comment https://forums.phpfreaks.com/topic/163186-solved-splitting-a-string-into-different-parts/#findComment-860988 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.