public static function skipStartAndLastTag($text, $tag = 'p') { $pattern = "=^<" . $tag . ">(.*)</" . $tag . ">\$=i"; preg_match($pattern, $text, $matches); if (isset($matches[1])) { return $matches[1]; } return $text; }