|
|
@ -33,7 +33,8 @@ class FindLinks { |
|
|
|
* @param $input string text block |
|
|
|
* @return mixed array of links in text block. |
|
|
|
*/ |
|
|
|
public static function inText(\string $input) { |
|
|
|
public static function inText($input) { |
|
|
|
if(!is_string($input)) return []; |
|
|
|
preg_match_all('/https?:\/\/[^ ]+/', $input, $matches); |
|
|
|
return array_unique($matches[0]); |
|
|
|
} |
|
|
@ -43,7 +44,9 @@ class FindLinks { |
|
|
|
* @param $input string text block |
|
|
|
* @return mixed array of links in text block. |
|
|
|
*/ |
|
|
|
public static function inHTML(\string $html) { |
|
|
|
public static function inHTML($html) { |
|
|
|
if(!is_string($input)) return []; |
|
|
|
|
|
|
|
$doc = new DOMDocument(); |
|
|
|
libxml_use_internal_errors(true); # suppress parse errors and warnings
|
|
|
|
@$doc->loadHTML(self::toHtmlEntities($html), LIBXML_NOWARNING|LIBXML_NOERROR); |
|
|
|