The following function puts all URLs/links from a string into an array. The function uses the preg_match function, and looks for URLs/links with http/https. Please note, the function does NOT search for hyperlink tags (
)- it looks for URL’s.1 2 3 4 5 6 7 8 9 | function getUrls($string) { $regex = '/https?\:\/\/[^\" ]+/i'; preg_match_all($regex, $string, $matches); return ($matches[0]); } $urls = getUrls($string); print_r($urls); |
0 comments:
Post a Comment