例子1 $str = "<b>example: </b><div align=left>this is a test</div>";
$p = "|<[^>]+>(.*?)</[^>]+>|i"; ?能幫我解釋下么?為什么運(yùn)行結(jié)果進(jìn)行匹配了兩次~
Array ( ? ?[0] => Array ? ? ? ?( ? ? ? ? ? ?[0] => example: ?? ? ? ? ? ?[1] =>
this is a test
) ? ?[1] => Array ? ? ? ?( ? ? ? ? ? ?[0] => example: ? ? ? ? ? ? [1] => this is a test ? ? ? ?) )?
2015-08-21
$p = "|<[^>]+>(.*?)</[^>]+>|i";//這里會(huì)緩存兩個(gè)值,一個(gè)是全部匹配到的值,還有一個(gè)是括號(hào)里面正則所匹配到的值
$p = "|<[^>]+>(?:.*?)</[^>]+>|i";//將正則改為這樣就行了,?:的意思是取消后向引用,類(lèi)似的解答可以訪(fǎng)問(wèn)下面的網(wǎng)址
?http://idcbgp.cn/qadetail/93469?