+44 (0)785 715 1348
office@bogdans.co.uk

Get the href, title or target of all links within an HTML page 0

Posted on 31, January 2014

in Category Web development


In order to do that you need to use preg_match_all just like explained below:

$url = '<a target="_blank" href="' . $query_logs_result["url"] . '">' . $query_logs_result["title"] . '</a>';
preg_match('~<a(.*?)href="([^"]+)"(.*?)>~', $url, $only_the_url);
echo $only_the_url[2];

This will show the hrefs, any other param of $only_the_url will return differently

0 Comments