jeremyhowell Posted December 14, 2009 Share Posted December 14, 2009 How can I use a function to loop through a string, and "have a look at" every word in the string, probably separated by a comma, and print them out, like this: word 1: xxxx word 2: xxxx word 3: xxxx etc, and loop till it has finished? Link to comment https://forums.phpfreaks.com/topic/185027-get-word-number-x-from-string/ Share on other sites More sharing options...
teamatomic Posted December 14, 2009 Share Posted December 14, 2009 $string = "one,two,three,four"; $string_array = explode(",",$string); $i=1; foreach($string_array as $word) { echo "word $i : $word<br>\n"; $i++; } HTH Teamaomic Link to comment https://forums.phpfreaks.com/topic/185027-get-word-number-x-from-string/#findComment-976686 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.