registerXPathNamespace("php", "http://php.net/ns/news"); // Loop over the items and store them in a array $STORE = []; foreach($sxe->entry as $item) { $url = (string)$item->link["href"]; $subject = (string)$item->category["term"]; if($subject == "conferences") { $subject = "conference"; } elseif($subject != "cfp") { // This is neither a conf announcement nor cfp, skip it continue; } $title = (string)$item->title; $lastDate = current($item->xpath("php:finalTeaserDate")); if(strtotime($lastDate) < strtotime("tomorrow")) { // finalTeaserDate has passed, skip it continue; } $STORE[$subject][$url] = $title; } // Create PHP readable array $write = '$CONF_TEASER = ' .var_export($STORE, true); // Write & close fwrite($out, ""); fclose($out); // If we don't have new data, delete file if (!@filesize("$outfile~")) { echo "'$outfile~' was empty, skipping\n"; unlink("$outfile~"); return; } // Replace real file with temporary file return rename("$outfile~", $outfile); }