Attro Posted July 25, 2006 Share Posted July 25, 2006 I'm trying to grab an RSS feed and strip the "[category]" crap out of the title and then fix the download link to point to the file instead of the page. That much works but it's printing every line twice. If I just do one or the other it works like it should and doesn't even double up the stuff that it's fixed.[code]<?phpheader("Content-type: text/xml");$link = "http://www.torrentspy.com/rss.asp?";if ($_GET['mode']) $link .= "mode=". $_GET['mode']. "&";if ($_GET['id']) $link .= "id=". $_GET['id']. "&";if ($_GET['db']) $link .= "db=". $_GET['db']. "&";if ($_GET['query']) $link .= "query=". $_GET['query']. "&";$lines = file($link);foreach ($lines as $line_num => $line) { echo ereg_replace("<title>\[.*\].(.*)<\/title>", "<title>\\1</title>", $line); echo ereg_replace("<link>http:\/\/www.torrentspy.com\/torrent\/(.*)\/.*<\/link>", "<link>http://www.torrentspy.com/download.asp?id=\\1</link>", $line);}?>[/code] Link to comment https://forums.phpfreaks.com/topic/15585-printing-everything-twice/ Share on other sites More sharing options...
effigy Posted July 25, 2006 Share Posted July 25, 2006 You are echoing each replace. Try this:[code]foreach ($lines as $line_num => &$line) { ereg... ereg... echo $line;}[/code] Link to comment https://forums.phpfreaks.com/topic/15585-printing-everything-twice/#findComment-63397 Share on other sites More sharing options...
Attro Posted July 25, 2006 Author Share Posted July 25, 2006 No more doubling up :) but now ereg_replace doesn't seem to want to do any replacing.Here's what I have now if it helps:[code]...foreach ($lines as $line_num => &$line) { ereg_replace("<title>\[.*\].(.*)<\/title>", "<title>\\1</title>", $line); ereg_replace("<link>http:\/\/www.torrentspy.com\/torrent\/(.*)\/.*<\/link>", "<link>http://www.torrentspy.com/download.asp?id=\\1</link>", $line); echo $line;}...[/code]Thanks for the help btw. Link to comment https://forums.phpfreaks.com/topic/15585-printing-everything-twice/#findComment-63412 Share on other sites More sharing options...
effigy Posted July 25, 2006 Share Posted July 25, 2006 I thought the reference might do it, but you'll have to assign:[code]$line = ereg...$line = ereg...echo $line;[/code] Link to comment https://forums.phpfreaks.com/topic/15585-printing-everything-twice/#findComment-63426 Share on other sites More sharing options...
Attro Posted July 25, 2006 Author Share Posted July 25, 2006 That worked. Thanks so much. :) Link to comment https://forums.phpfreaks.com/topic/15585-printing-everything-twice/#findComment-63436 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.