etrader Posted June 21, 2011 Share Posted June 21, 2011 In a string containing a simple sentence as $str="word1 word2 word3 word4 word5" I want to split every two words. Actually, performing explode() for every other 'space' (not all of them). To create $array[0]="word1 word2"; $array[1]="word3 word4"; $array[2]="word5"; Any idea? Link to comment https://forums.phpfreaks.com/topic/239988-how-to-split-every-two-words-in-a-sentence/ Share on other sites More sharing options...
HDFilmMaker2112 Posted June 21, 2011 Share Posted June 21, 2011 There's about 5 different ways to do it here: http://stackoverflow.com/questions/857441/php-explode-over-every-other-word-with-a-twist Link to comment https://forums.phpfreaks.com/topic/239988-how-to-split-every-two-words-in-a-sentence/#findComment-1232753 Share on other sites More sharing options...
etrader Posted June 21, 2011 Author Share Posted June 21, 2011 Nice reference! I like when facing such creative ideas to handle an issue in php Link to comment https://forums.phpfreaks.com/topic/239988-how-to-split-every-two-words-in-a-sentence/#findComment-1232850 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.