Revision: 59818
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 3, 2012 12:26 by dmertl
Initial Code
/** * Returns the substring between two strings, delimiters not included * @param string $string Haystack * @param string $start Starting delimiter * @param string|null $end Ending delimiter, if omitted will return the rest of the string * @return bool|string The substring between $start and $end or false if either string is not found */ function substr_between($string, $start, $end=null) { if(($start_pos = strpos($string, $start)) !== false) { if($end) { if(($end_pos = strpos($string, $end, $start_pos + strlen($start))) !== false) { return substr($string, $start_pos + strlen($start), $end_pos - ($start_pos + strlen($start))); } } else { return substr($string, $start_pos); } } return false; }
Initial URL
Initial Description
Get the substring between two strings
Initial Title
Substring between two strings
Initial Tags
Initial Language
PHP