Answers for "get the href in string regex php"

PHP
1

get the href in string regex php

$html = 'some text here<a href="http://www.mydomain.com/page.html">URL</a> some text here as well';

$url = preg_match('/<a href="(.+)">/', $html, $match);

$info = parse_url($match[1]);

echo $info['scheme'].'://'.$info['host'];
Posted by: Guest on April-08-2022

Browse Popular Code Answers by Language