Home > Backend Development > PHP Tutorial > php正则表达式获取div标签中的a标签href有关问题

php正则表达式获取div标签中的a标签href有关问题

WBOY
Release: 2016-06-13 13:12:33
Original
1421 people have browsed it

php正则表达式获取div标签中的a标签href问题
php正则表达式获取div标签中的a标签href问题


 

     

  •  


  •  




页面上有很多
  • 标签 都不是我想要的,我想要的就是在这个div标签中的
  • 里面的A连接
    用正则的话必须先获取div里面的内容,在获取
    • 里面A标签连接


      效果:
      Array
      (
        [0] => http://news.cjcp.com.cn/2012/0917/4316066.html
        [1] => http://news.cjcp.com.cn/2012/0917/4316065.html
        [2] => http://news.cjcp.com.cn/2012/0917/4316064.html
        [3] => http://news.cjcp.com.cn/2012/0917/4316063.html
        [4] => http://news.cjcp.com.cn/2012/0917/4316062.html
        [5] => http://news.cjcp.com.cn/2012/0917/4316061.html
        [6] => http://news.cjcp.com.cn/2012/0917/4316060.html
      )

      ------解决方案--------------------
      PHP code
      $str=
        
      Copy after login
      txt; preg_match('/
      (.*)/isU',$str,$m); preg_match_all('/
  • Related labels:
    source:php.cn
    Statement of this Website
    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
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template