Home >Backend Development >PHP Tutorial >求助:怎么取出一段字符串中的链接

求助:怎么取出一段字符串中的链接

WBOY
WBOYOriginal
2016-06-23 14:27:47961browse

把下面一段字符串中的href地址取出来:

<a href="www.1.com" target="_blank">文章标题</a><a href="www.2.com" target="_blank">1-1</a> <a href="www.3.com" target="_blank">1-2</a> <a href="www.4.com" target="_blank">1-3</a>

需要得到这样的格式:
<i>www.1.com</i><i>www.2.com</i><i>www.3.com</i><i>www.4.com</i>

谢谢!


回复讨论(解决方案)

$s=<<'.implode('
  • ',$m[1]).'
  • ';


    $str = '文章标题
    1-1 1-2 1-3';
    preg_match_all('',$str,$val);
    foreach($val[1] as $v){
        $newstr[]= "$v";
    }
    print_r(implode("",$newstr));

    谢谢!

    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn