I'm trying to just read even numbered lines from a text file. I know about the modulo(%) operator which I could put in a loop and attain the desired result, but somehow I can't figure out how to put it to use here.
Here is the code I have:
<?php
$url = "somedomain/something";
$lines = file('text.txt', FILE_IGNORE_NEW_LINES);
foreach ($lines as $line_num => $line) {
echo "<br />
" . "Line #<b>{$line_num}</b> :" . (htmlspecialchars($line));
$dom = new DOMDocument;
$dom->loadHTMLFile($url . $line);
foreach ($dom->getElementsByTagName('p') as $node) {
// do stuff with $node
echo $node->nodeValue, "
";
}
}
?>