Created
May 12, 2019 13:37
-
-
Save GodSaveEarth/6df584003e44271e5006d10034c7f96e to your computer and use it in GitHub Desktop.
getBetween php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getBetween($string, $start = "", $end = "", $include_start_end=false){ | |
$pos1 = strpos($string, $start); | |
if($pos === false) return ''; | |
$apos1 = $pos1+strlen($start); | |
$pos2 = strpos($string, $end, $apos1); | |
$apos2 = $pos2+strlen($end); | |
if($include_start_end) | |
return substr($string, $pos1, max(0, $apos2-$pos1)); | |
return substr($string, $apos1, max(0, $pos2-$apos1)) ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment