Hello,
I am trying to write a function to get the string between two other strings in a string of text.
This is what I have so far:
function retrieveBetween($subject, $start, $end) {
$matchPattern = "/.*$start.*$end.*/";
if (preg_match($matchPattern, $subject, $matches)) {
return $matches[0];
} else {
return "Could not find valid match.";
}
}
However it keeps returning "could not find valid match."
I dont think I have a proper handle on regular expressions yet.
Could someone please tell me what is wrong with this code?
Thanks.