Because you want to do something like a professional search engine recently, you need to crawl all the hyperlinks in your pages. Everyone help test all of a sudden, the following code can be for all standard hyperlinks.
Generic HTML standard hyperlink parameter gets the regular expression test
Because you want to do something like a professional search engine recently, you need to crawl all the hyperlinks in your pages.
Everyone help test all of a sudden, the following code can be for all standard hyperlinks.
The test code is as follows:
<?php
// --------------------------------------------------------------------------
File name:Noname1.php
Description: Universal link parameter get regular expression test
REQUIREMENT:PHP4 (http://www.php.net)
Copyright (C), Honestqiao, Reserved, all Rights.
Author:honestqiao (honestqiao@hotmail.com)
Parameter description:
$strSource: HTML pages that contain standard links
$strResult: Results of processing
Additional Instructions:
Standard links, using the links contained in <a></a> situation
// --------------------------------------------------------------------------
$strSource = <<<a href=1.htm>t1</a>
<a href= ' 2.htm ' >t2</a>
<a href= "3.htm" >t3</a>
<a href=4.htm class=link>t4</a>
HTML;
Preg_match_all ('/<a.*: \\t\\r\\n)? href=[\ ' "]? (. +?) [\'"]? (:(?: \\t\\r\\n) +.*? > (. +?) <\/a.*?>/sim ', $strSource, $strResult, Preg_pattern_order);
for ($i = 0; $i < count ($strResult [1]); $i + +)
{
printf ("%d href= (%s) title= (%s) \ n", $i, $strResult [1][$i], $strResult [2][$i]);
}
?>
If your test data conforms to the standard link but is not being processed here, please tell me the test data and your test environment.
Thank you.