Home >Backend Development >PHP Tutorial >PHP Get all hyperlink functions on a page_PHP tutorial

PHP Get all hyperlink functions on a page_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:40:451205browse

Simple function to get all hyperlinks on a page:

  1. function get_all_url($cnstr){
  2. preg_match_all(/" ] )["|]?s*[^>]*>([^>] )/i,$cnstr,$arr);
  3. return array(name=>$arr[2],url=>$arr[1]);
  4. }

  5. //Call function
  6. $url = www.ite5e.com;
  7. echo get_all_url($url);
  8. ?>

It’s very simple to use, just pass in a URL address.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486187.htmlTechArticleA simple function to get all hyperlinks on a page: ?php function get_all_url($cnstr){ preg_match_all(/as href=["|]?([^" ] )["|]?s*[^]*([^] )/a/i,$cnstr,$arr); return array(name...
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