I am working on a schedule system that collects information from a RSS feed. However, when I try to strip the necessary segment from the RSS preg_match returns it as invalid.
//Finds the day by stripping data from the myDragonnet RSS feed.
function schedule($given_date) {
$url = "http://mydragonnet.hkis.edu.hk/schedule/day_schedule_rss.php?schedule_id=1";
$rss = simplexml_load_file($url);
$date = date("~jS M Y~", strtotime($given_date));
if($rss) {
foreach($rss->channel->item as $item) {
foreach ($item->title as $story) {
if (strpos($date, $story) !== false) {
preg_match("/Day (\d+)/", $story, $m);
break; // stop searching
}
}
}
}
return $m[1];
}
The function : <?php echo schedule('01/24/2010'); ?>
This is the error I’m getting –
Warning: preg_match() [function.preg-match]: Unknown modifier '/' in ***/class.schedule.php on line 31
try this: