Thomisback Posted July 19, 2008 Share Posted July 19, 2008 Hi, I have got a function to search for a substring but I want to find all the substrings, not just one, so I need a foreach statement (I think?). Although I have no idea where to put it, this is my function: function get_string_between($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); } Kind regards Link to comment https://forums.phpfreaks.com/topic/115581-foreach-string/ Share on other sites More sharing options...
ignace Posted July 19, 2008 Share Posted July 19, 2008 you are missing a parameter, what are you looking for? Link to comment https://forums.phpfreaks.com/topic/115581-foreach-string/#findComment-594285 Share on other sites More sharing options...
irvieto Posted July 19, 2008 Share Posted July 19, 2008 Hi there. What about a regular expression for the substring lookup? http://php.net/manual/en/function.preg-match-all.php Link to comment https://forums.phpfreaks.com/topic/115581-foreach-string/#findComment-594290 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.