aashcool198 Posted June 30, 2009 Share Posted June 30, 2009 Hi, Given a string i want to extract sub string before the first space occurs E.g in $string="php freaks"; i want to extract the first word that is "php". if $string = "your name"; i want to extract "your". How can i do it? Quote Link to comment https://forums.phpfreaks.com/topic/164224-solved-extracting-substring/ Share on other sites More sharing options...
trq Posted June 30, 2009 Share Posted June 30, 2009 $string = "your name"; $string = explode(' ', $string, 1); echo $string[0]; Quote Link to comment https://forums.phpfreaks.com/topic/164224-solved-extracting-substring/#findComment-866248 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.