Jump to content

Foreach string


Thomisback

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.