Jump to content

Parse a RSS url and then rename text in its output


forzatio

Recommended Posts

Hi there I have some rss feed with wrong text in it, I need to replace the wrong text with my own good text.
But that needs to be done after it is parsed fully into the php page.

I have this magpie script used to parse it into the page.

My problem is that I can't get the bad words replaced by the good words after the rss is parsed in the php page.

[code]
<?php require_once 'rss_fetch.inc';

$url = 'http://rssfile.com/feed?hl=en&q=badname&output=rss';
$rss = fetch_rss($url);

foreach ($rss->items as $item ) {

$description = $item[description];
$url = $item[link];
$title = $item[title];



echo "<a href=$url>$title</a><br><br>$description<br><br>";
}


echo str_replace('badname','goodname','$item[description]');

?>
[/code]
You're doing the change after the loop, and after the echo even.

[code]<?php require_once 'rss_fetch.inc';

$url = 'http://rssfile.com/feed?hl=en&q=badname&output=rss';
$rss = fetch_rss($url);

foreach ($rss->items as $item ) {

$description = str_replace('badname','goodname',$item['description']);
$url = $item[link];
$title = $item[title];



echo "<a href=$url>$title</a><br><br>$description<br><br>";
}

?>[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.