Dustin013 Posted February 11, 2009 Share Posted February 11, 2009 I have a form field post which is sending the variable '$fullname' to a script. What I need to do is split that name into two variables. So if $fullname is "John Smith" I need to create $firstname=John and $lastname=Smith, using the space as the identifier. What the best method to do this? Link to comment https://forums.phpfreaks.com/topic/144840-split-a-variable-into-2-variables/ Share on other sites More sharing options...
kenrbnsn Posted February 11, 2009 Share Posted February 11, 2009 explode and list <?php $fullname = 'John Smith'; list($firstname,$lastname) = explode(' ',$fullname); ?> Ken Link to comment https://forums.phpfreaks.com/topic/144840-split-a-variable-into-2-variables/#findComment-760030 Share on other sites More sharing options...
Dustin013 Posted February 11, 2009 Author Share Posted February 11, 2009 Sweet man! Thanks! Link to comment https://forums.phpfreaks.com/topic/144840-split-a-variable-into-2-variables/#findComment-760032 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.