Jump to content

Printing everything twice


Attro

Recommended Posts

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]<?php
header("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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.