Home >php教程 >php手册 >PHP 取得一个页面上的所有超链接函数

PHP 取得一个页面上的所有超链接函数

WBOY
WBOYOriginal
2016-06-13 10:39:37847browse

取得一个页面上所有超链接的简单函数:

  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. //调用函数
  6. $url = www.ite5e.com;
  7. echo get_all_url($url);
  8. ?>

使用很简单,传一个URL地址进去就可以啦。

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