ssnelgrove Posted March 24, 2014 Share Posted March 24, 2014 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> Quote Link to comment https://forums.phpfreaks.com/topic/287219-rss-crawl-for-tv-studio-set/ Share on other sites More sharing options...
ginerjm Posted March 24, 2014 Share Posted March 24, 2014 Read up on the substr function in the php manual. Quote Link to comment https://forums.phpfreaks.com/topic/287219-rss-crawl-for-tv-studio-set/#findComment-1473684 Share on other sites More sharing options...
ssnelgrove Posted March 25, 2014 Author Share Posted March 25, 2014 (edited) 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 March 25, 2014 by ssnelgrove Quote Link to comment https://forums.phpfreaks.com/topic/287219-rss-crawl-for-tv-studio-set/#findComment-1473788 Share on other sites More sharing options...
ginerjm Posted March 25, 2014 Share Posted March 25, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/287219-rss-crawl-for-tv-studio-set/#findComment-1473805 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.