Jump to content

RSS crawl for TV Studio Set


ssnelgrove

Recommended Posts

So a little background I have to create a RSS feed for a crawl for a monitor wall above out studios news desk that only accepts the description field so I have made a page that takes another RSS feed and only displays the description field and adds some spaces then a pipe with a few more spaces and makes it all CAPS

 

Making it look like this

CRAWL ITEM 01    |    CRAWL ITEM 02    |    CRAWL ITEM 03    |

 

The problem is I need the get rid of the ending pipe

 

Making it look like this

CRAWL ITEM 01    |    CRAWL ITEM 02    |    CRAWL ITEM 03

 

This is what I have so far If anyone can show me how to get rid of the ending pipe would be great. I have read about the implode function but don’t know how to implement it I and very novice with php, most of the code I got off another forum

 

And yes a lot of things are commented out incase I need then in the future

 

Thx

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>

<?php
$rss = new DOMDocument();
$rss->load('http://site.com/temp/rss_clean_feed/sample.rss');
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
);
array_push($feed, $item);
}
$limit = 8;
for($x=0;$x<$limit;$x++) {
$title = str_replace(' & ', ' & ', $feed[$x]['title']);
#$link = $feed[$x]['link'];
$description = $feed[$x]['desc'];
$description = strtoupper($description);

#$date = date('l F d, Y', strtotime($feed[$x]['date']));


echo '<item>' . "\n";


#echo '<title>'.$title.'</title>';

echo '<description>'.$description.'      |     ';
echo '</description>' . "\n";
echo '</item>' . "\n";

}
?>

</channel>

</rss>
Link to comment
https://forums.phpfreaks.com/topic/287219-rss-crawl-for-tv-studio-set/
Share on other sites

i don't understand what the substr does

 

I have tryed the implode and can't get it to work here is what I have

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<description>News Ticker RSS </description>
<?php
$rss = new DOMDocument();
$rss->load('http://site.com/temp/rss_clean_feed/sample.rss');
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
);
array_push($feed, $item);
}
$limit = 8;
for($x=0;$x<$limit;$x++) {
$title = str_replace(' & ', ' & ', $feed[$x]['title']);

#$link = $feed[$x]['link'];

$description = $feed[$x]['desc'];
$description = strtoupper($description);

#$date = date('l F d, Y', strtotime($feed[$x]['date']));

echo '<item>' . "\n";

#echo '<title>'.$title.'</title>';

echo '<description>';
echo implode("      |     ",$description);




#echo '<description>'.$description.'      |     ';
echo '</description>' . "\n";
echo '</item>' . "\n";

}
?>
<ttl>1 </ttl>
</channel>
</rss>


but I keep getting

 

Warning: implode(): Invalid arguments passed in /var/www/rss_clean_feed/index.php on line 34

 

What am I not getting ?

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.