Skip to content

Instantly share code, notes, and snippets.

@jrean
Created May 5, 2015 06:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrean/9444d066e3572ef9eb76 to your computer and use it in GitHub Desktop.
Save jrean/9444d066e3572ef9eb76 to your computer and use it in GitHub Desktop.
Extract content inside delimiters
/**
* Extract content inside delimiters.
*
* @param string $start
* @param string $end
* @return string Extracted content.
*
* @source
* http://www.bitrepository.com/extract-content-between-two-delimiters-with-php.html
*/
protected function extract_unit($string, $start, $end)
{
$pos = stripos($string, $start);
$str = substr($string, $pos);
$str_two = substr($str, strlen($start));
$second_pos = stripos($str_two, $end);
$str_three = substr($str_two, 0, $second_pos);
return trim($str_three);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment