指定原始字符串,给定开始和结尾字符串,获得这两个字符串之间的子字符串的php函数
/** * 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; }