I'm reading in a file's contents as a string. From this string, I want to get a substring. All I know is the text that is beginning of the substring and the end ot the substring, I do not know what is contained in the string between the beginning and the end. This will occur more than once in the main string.

Example String:

$fileContents = "StartblahblahblahEndStartblahEndStartblahblahblahbalhEnd"

I need to get each substring between start and end, and preferrably load each substring into an array. Can someone please point me in the right direction. Thanks.

// Delimiters may be slash, dot, or hyphen
$date = "04/30/1973";
list($month, $day, $year) = split('[/.-]', $date);
echo "Month: $month; Day: $day; Year: $year<br />\n";

This help at all?

The split function is depreciated, although this is not anything too critical where I couldn't use it. My problem is that my delimiter is a string, so I would need to use something like explode(). But, explode only takes one delimiter, and I have two.

I need something like substr(), except I need to use strings as the start and end positions, not integers.

preg_match_all() with this expression should work


Glad to hear.

Please mark this thread as solved.