我用preg_match_all来截取字符串
$ziliao="<a href=mulu_222780.html>体尊</a><td class=xt>";
preg_match_all('/<a href=([^>])*>/',$value,$Books);按照文档上的结果$Books[0][0]=<a href=mulu_222780.html>;$Books[1][0]=mulu_222780.html;
但是我现在的得到的结果 $Books[1][0]=1;
哪怕$Books[1]的长度为5、6、7。都是同样的结果各位帮忙看看
$ziliao="<a href=mulu_222780.html>体尊</a><td class=xt>";
preg_match_all('/<a href=([^>])*>/',$value,$Books);按照文档上的结果$Books[0][0]=<a href=mulu_222780.html>;$Books[1][0]=mulu_222780.html;
但是我现在的得到的结果 $Books[1][0]=1;
哪怕$Books[1]的长度为5、6、7。都是同样的结果各位帮忙看看
$ziliao="<a href=mulu_222780.html>体尊</a><td class=xt>";
preg_match_all('/<a href=([^>])*>/',$ziliao,$Books); // 是对$ziliao匹配,不是$value
print_r($Books);
$ziliao="<a href=mulu_222780.html>体尊</a><td class=xt>";
preg_match_all('/<a href=(.*?[^\>])>/',$ziliao,$Books);print_r($Books);
/****是你想要的么?
Array
(
[0] => Array
(
[0] => <a href=mulu_222780.html>
)
[1] => Array
(
[0] => mulu_222780.html
)
)
***/
我这结果出来是
Array
(
[0] => Array
(
[0] => <a href=mulu_222780.html>
)
[1] => Array
(
[0] => 1
)
)
(
[0] => Array
(
[0] => <a href=mulu_121830.html>仙锻</a><td class=xt>
[1] => <a href=mulu_163417.html>异世邪君</a><td class=xt>
[2] => <a href=mulu_104622.html>九界独尊</a><td class=xt>
[3] => <a href=mulu_105716.html>星际游轮</a><td class=xt>
[4] => <a href=mulu_88105.html>鸿钧之师</a><td class=xt>
[5] => <a href=mulu_75923.html>长生界</a><td class=xt>
[6] => <a href=mulu_163952.html>魔法世界之机械召唤</a><td class=xt>
[7] => <a href=mulu_180834.html>英雄无敌之超级英雄</a><td class=xt>
[8] => <a href=mulu_179867.html>回到大明当才子</a><td class=xt>
) [1] => Array
(
[0] => l
[1] => l
[2] => l
[3] => l
[4] => l
[5] => l
[6] => l
[7] => l
[8] => l
))
这是我得出来的结果
不知道是哪里错误了
$ziliao="<a href=mulu_222780.html>体尊</a><td class=xt>";
preg_match_all('/<a href=([^>]*)>/',$ziliao,$Books); //这样,括号要把*包进去才行
print_r($Books);
?>
那就要'/<a href=([^>]*)>/i' 你的是在外面 那么你匹配的就是>以外的任意字符 当然是1了 字符串有几个非'>'字符 你这么就匹配出几个1