Needing urgent help with XML parser.
OUR XML parser only shows three future events from an XML feed, however it needs to show future events starting TODAY as not tomorrow. Our PHP guy is out and I need to get this altered ASAP, can anyone help alter this code?
$testfn = 'http://website.com';
//function to encode and replace certain things that will make an XML file not well formed ie '&' => '&'
$str = utf8_encode(str_replace('&', '&', file_get_contents($url)));
/*$str = '<?xml version="1.0" encoding="UTF-8"?>' . $str; */
$xmlobject = simplexml_load_string($tempstr);
function getNextEvents($object, $numtofetch = 3)
//function to recurse through object to find the next x number of events in the future. alter passed value of $numtofetch to change the date range of events.
$numtofetch = 3;
$found = array();
$currentdate = time();
foreach($object->Events->Event as $event)
$eventtime = strtotime((string) $event->EventStartDateTime);
if ($eventtime >= $currentdate) !!!!!! not returning a result if event is today !!!!!!
$found = array_reverse($found);
//found now contains all matching events in reverse date order ie next in line to most distant in future
//trim the array to first 3 and return
return array_slice($found, 0, $numtofetch);
//call function to prepare XML string for passing to SIMPLE XML
$xmlstr = prepareXML($testfn);
//call function to load XML using string produced
$xmlObj = loadXML($xmlstr);
//call to find events in categories...
$events = getNextEvents($xmlObj);