note 61639 added to function.preg-match

From: Date: Wed, 08 Feb 2006 08:21:05 +0000
Subject: note 61639 added to function.preg-match
Groups: php.notes 
Request: Send a blank email to php-notes+get-103292@lists.php.net to get a copy of this message
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>"; } } ?> ---- Server IP: 193.190.198.20 Probable Submitter: 213.49.188.138 ---- Manual Page -- http://www.php.net/manual/en/function.preg-match.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+61639 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61639&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61639&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61639&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61639&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61639&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61639&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61639&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+61639&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#103292) next »