I am currently using the function below to match all the "hrefs" on the page but I am also trying to grab the text inside the actual url tag My Current Code protected function _get_desc() { if (!empty($this->markup)){ preg_match_all('/<a([^>]+)\>(.*?)\<\/a\>/i', $this->markup, $links); return !empty($links[1]) ? $links[1] : FALSE; } } PHP: I would want to grab the "ShopABC" text. Sponsored by <a href="/website/6/swp/" target="_blank">ShopABC</a> HTML: I need to modify: /<a([^>]+)\>(.*?)\<\/a\>/i Any help would be appreciated, I'm stuck! Thanks!
Try this: protected function _get_desc() { if (!empty($this->markup)){ preg_match_all('/(<a.*>)(.*)(<\/a>)/i', $this->markup, $links, PREG_SET_ORDER); return !empty($links[0][2]) ? $links[0][2] : FALSE; } } PHP: