Get content between two strings PHP

You may as well use substr and strpos for this.

$startsAt = strpos($out, "{FINDME}") + strlen("{FINDME}");
$endsAt = strpos($out, "{/FINDME}", $startsAt);
$result = substr($out, $startsAt, $endsAt - $startsAt);

You’ll need to add error checking to handle the case where it doesn’t FINDME.

Leave a Comment