note 61639 deleted from function.preg-match by colder

From: Date: Mon, 18 Jun 2007 18:29:01 +0000
Subject: note 61639 deleted from function.preg-match by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-127617@lists.php.net to get a copy of this message
Note Submitter: brunosermeus at gmail dot com ---- I've created this function to let you see the ease of using regular expressions instead of using some class that are available online, and that are verry slow in proceeding. This function is an RSS-reader that only need the URL as parameter. <?php function RSSreader($url) { $rssstring = file_get_contents($url); preg_match_all("#<title>(.*?)</title>#s",$rssstring,$titel); preg_match_all("#<item>(.*?)</item>#s",$rssstring,$items); $n=count($items[0]); for($i=0;$i<$n;$i++) { $rsstemp= $items[0][$i]; preg_match_all("#<title>(.*?)</title>#s",$rsstemp,$titles); $title[$i]= $titles[1][0]; preg_match_all("#<pubDate>(.*?)</pubDate>#s",$rsstemp,$dates); $date[$i]= $dates[1][0]; preg_match_all("#<link>(.*?)</link>#s",$rsstemp,$links); $link[$i]= $links[1][0]; } echo "<h2>".$titel[1][0]."</h2>"; for($i=0;$i<$n;$i++) { $timestamp=strtotime($date[$i]); $datum=date('d-m-Y H\hi', $timestamp); if(!empty($title[$i])) echo $datum."\t\t\t <a href=".$link[$i]." target=\"_blank\">".$title[$i]."</a><br>"; } } ?>

« previous php.notes (#127617) next »