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
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 ?

Edited by ssnelgrove
Link to comment
Share on other sites

What are you trying to do with implode? 

 

Did you read up on substr in the manual?  You wanted to remove the last pipe symbol which is the last character of your string, no?  The substr function is made just for something like that.

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.