How do I alternate these foreach statements in the sense that after one result of the first foreach statement is echoed one result from the second foreach statement will be echoed? Here are the two foreach statements.
foreach($anchors as $a) {
$text = $a->nodeValue;
$href = $a->getAttribute('href');
$i++;
if ($i > 16) {
if (strpos($text, "by owner") === false) {
if (strpos($text, "map") === false) {
echo "<a href =' ".$href." '>".$text."</a><br/>";
}
}
}
}
foreach($span as $s) {
echo "<br>".$s->nodeValue."<br>" ;
}
Literally you cannot "merge" two foreach statements, but you can use each() function as workaround. Place this somewhere in first cycle:
list(,$s) = each($span);
echo "<br>".$s->nodeValue."<br>" ;