Skip to content

Instantly share code, notes, and snippets.

@rantastic
Last active October 6, 2015 15:28
Show Gist options
  • Save rantastic/3014426 to your computer and use it in GitHub Desktop.
Save rantastic/3014426 to your computer and use it in GitHub Desktop.
PHP: Gets the string between two other strings
function getStringBetween($before,$after,$haystack){
$start=strpos($haystack,$before)+strlen($before);
$finish=strpos($haystack,$after,$start);
$length = $finish - $start;
return substr($haystack, $start, $length);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment