多维数组一直没能找到一个直接的答案尚未..我的数组$ sitematches:打印从preg_match_all
if (preg_match('/<start>(.*?)<finish>/s', $source, $matches)) {
if (preg_match_all('/<a\s[^>]*href=\"([^\"]*)\"[^>]*>(.*)<\/a>/siU', $matches[1], $sitematches)); {
print_r($sitematches);
}
}
生产:
Array
(
[0] => Array
(
[0] => <A HREF="http://site1.com">aaa</A>
[1] => <A HREF="http://site2.com">bbb</A>
[2] => <A HREF="http://site3.com">ccc</A>
[3] => <A HREF="http://site4.com">ddd</A>
)
[1] => Array
(
[0] => http://site1.com
[1] => http://site2.com
[2] => http://site3.com
[3] => http://site4.com
)
[2] => Array
(
[0] => aaa
[1] => bbb
[2] => ccc
[3] => ddd
)
)
我怎么能输出:
1 - aaa - http://site1.com
2 - bbb - http://site2.com
3 - ccc - http://site3.com
4 - ddd - http://site4.com
很好,避免计数因此效率更高,对不对? – Adrian33 2013-04-06 12:19:35
我没有知道,但我认为这很可能...写出你自己的microbenchmark ;-) – bwoebi 2013-04-06 12:21:11
谢谢你回答这个问题,应该让你为更困难的事情变暖。 – Adrian33 2013-04-06 12:25:41