Extracts all links from HTML

Uses regex to find all links in HTML and return it in array. Read more.

php
fork add to bundle source
function extract_html_links($html) { preg_match_all('/<a[^>]+href=["\']([^"\']+)["\']/misu', $html, $matches); return $matches ? $matches[1] : null; }

usage

load_function('extract_html_links'); $html = '<a href="/da"></a> <a href="/1"></a>, <a href="/2"></a>'; $links = extract_html_links($html); print_r($links); // Array // ( // [0] => /da // [1] => /1 // [2] => /2 // )
← how to use this in app?
create log ...inout