format_rss_item

Definition

format_rss_item($title, $link, $description, $args = array())
includes/common.inc, line 666

Description

Format a single RSS item.

Arbitrary elements may be added using the $args associative array.

Related topics

Namesort iconDescription
FormattingFunctions to format numbers, strings, dates, etc.
Input validationFunctions to validate user input.

Code

<?php
function format_rss_item($title, $link, $description, $args = array()) {
  $output = "<item>\n";
  $output .= ' <title>'. check_plain($title) ."</title>\n";
  $output .= ' <link>'. check_url($link) ."</link>\n";
  $output .= ' <description>'. check_plain($description) ."</description>\n";
  foreach ($args as $key => $value) {
    if (is_array($value)) {
      if ($value['key']) {
        $output .= ' <'. $value['key'];
        if (is_array($value['attributes'])) {
          $output .= drupal_attributes($value['attributes']);
        }

        if ($value['value']) {
          $output .= '>'. $value['value'] .'</'. $value['key'] .">\n";
        }
        else {
          $output .= " />\n";
        }
      }
    }
    else {
      $output .= ' <'. $key .'>'. check_plain($value) ."</$key>\n";
    }
  }
  $output .= "</item>\n";

  return $output;
}
?>
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.