我正在從一個RSS提要收集信息的時間表系統。但是,當我嘗試從RSS中剝離必要的段時,preg_match將其視爲無效。preg_match問題
//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];
}
功能:<?php echo schedule('01/24/2010'); ?>
這是我得到的錯誤 -
Warning: preg_match() [function.preg-match]: Unknown modifier '/' in ***/class.schedule.php on line 31
我將刪除! preg_match之前? – 2011-01-24 03:20:59
不,你不...... – codaddict 2011-01-24 03:22:48