0

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.

3
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by quasipickle
0
<?php
// 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?

0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.