我试图过滤特定元素,然后一旦找到文本,我想记录位置并突破each
方法。但我无法摆脱它我得到 PHP 错误Cannot break/continue 2 levels
这是我正在使用的当前代码:
$crawler->filter('#title')->each(function ($node) use ($new_text, $new_place, $place, $number) {
// If number is found, record its place
if (strpos($node->text(), $number) !== false) {
$new_place = $place;
$new_text = $node->text();
break;
}
$place++;
});