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 Quote 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? Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/115581-foreach-string/#findComment-594290 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.