]*>.*?<\/p>/is', $html, $matches); if (count($matches[0]) === 1) { return preg_replace( ['/^\s*]*)>/i', '/<\/p>\s*$/i'], ['', ''], $html ); } return $html; } }