I am trying to filter through the specific element and then once the text is found, I want to record the position and break out of the each
method. But I cannot break out of it I get the PHP error Cannot break/continue 2 levels
Here's the current code I'm working with:
$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++;
});