当在字符串中找到“最佳匹配”时,下面的脚本应该结束,但即使我知道它最终被发现脚本仍在运行。请帮我解决我的错误。请帮我修复这个PHP,而声明
$end = "1";
while ($end != 2) {
foreach($anchors as $a) {
$i = $i + 1;
$text = $a->nodeValue;
$href = $a->getAttribute('href');
//if ($i<80) {
//if (strpos($item, ".$array.") == false) {
//}
if (strpos($text, "best match") == true) {
$end = "2";
}
if (strpos($text, "by owner") === false) {
if (strpos($text, "map") === false) {
if ($i > 17) {
echo "<a href =' ".$href." '>".$text."</a><br/>";
}
}
}
}
//$str = file_get_contents($href);
//$result = (substr_count(strip_tags($str),"ipod"));
//echo ($result);
}
解决您的缩进,你会看到这个问题。 – 2013-04-20 03:01:20
为什么'$ end'是一个既可以是“1”又可以是“2”的字符串,并与整数进行比较?为什么不把它做成一个布尔值?为什么不使用'break 2'?如果'strpos'的结果是'0',它不会与'true'相比(反正毫无意义的比较)。 – Ryan 2013-04-20 03:01:50