PHP Regular Expressions get all links to content, PHP regular expressions get
Method One:
function Get_all_url ($code) { preg_match_all ('/"']+) [" | ']? S*[^>]*> ([^>]+)/I ', $code, $arr); Return Array (' name ' = = $arr [2], ' url ' = = $arr [1]); }
Method Two:
/** * Date 2015-07-24 **/$site =substr ($url, 0,strpos ($url, "/", 8));//Site $base =substr ($url, 0,strrpos ($url, "/") +1);// The directory where the file is located $fp = fopen ($url, "R"),//Open the URL while (!feof ($FP)) $contents. =fread ($fp, 1024x768);//$pattern = "|href=[" "]? ([^ '"]+) [' "]|u"; Preg_match_all ($pattern, $contents, $regarr, preg_set_order);//Match All href= for ($i =0; $i
";//root directory else echo" link ". ( $i + 1). ":" $base. $regarr [$i][1]. "
";//Current directory Elseecho" link ". ($i + 1). ":" $regarr [$i][1]. "
";//relative path}fclose ($FP);
The above mentioned is the whole content of this article, I hope you can like.
http://www.bkjia.com/PHPjc/1038214.html www.bkjia.com true http://www.bkjia.com/PHPjc/1038214.html techarticle PHP Regular Expressions get all links to content, PHP regular expression get method one: function Get_all_url ($code) {preg_match_all ('/as+href=[' | ') ([^"' ]+) ["|'] s*[^]* ([^]+)/a/i ', $code,...