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
| Name | Description |
|---|---|
| Formatting | Functions to format numbers, strings, dates, etc. |
| Input validation | Functions 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;
}
?> 