程序代码
<?php
$html = <<<HTML
<a href="http://www.111cn.net /?source=2008hao123banner">a1</a>
<a href="http://www.111cn.net /?source=2009hao123banner">a2</a>
HTML;
// echo $html;
$m = array();
preg_match_all("|<a href=\"http://www.111cn.net /\?source=(\d+)hao123banner\">(.*?)</a>|",$html,$m);
print_r($m);
运行结果
Array
(
[0] => Array
(
[0] => <a href="http://www.111cn.net /?source=2008hao123banner">a1</a>
[1] => <a href="http://www.111cn.net /?source=2009hao123banner">a2</a>
)
[1] => Array
(
[0] => 2008
[1] => 2009
)
[2] => Array
(
[0] => a1
[1] => a2
)
)
时间: 2024-09-22 19:38:43