\n\n\n"; // cycle through each item in $channel_elements foreach($channel_elements as $element) { // if the current element is present in $channel_vars lets process it if(!empty($channel_vars['".$element."'])) { // add the element and value into the rss feed section $final_feed .= "<".$element.">".$item_vars['".$element."']."\n"; } } // $item_vars may contain more than one item, lets do all of them for($i=0,$i".$item_vars[$i]['".$element."']."\n"; } } // close the item section $final_feed .= "\n"; } // close the channel section and also the feed $final_feed .= "\n"; // return what we've just done to the user return $final_feed; } // output the feed to browser (or file) function output($feed, $file=null,$path=null) // if $file and $path are specified we need to write to a file if(!empty($file) || !empty($path)) { // use $fh as a handle and open the file for writing $fh = fopen($path."/".$file, "w") or die("Could not open file"); // write our feed into the $fh handle fwrite($fh, $feed) or die("Could not write to file."); // now lets close the file to save it fclose($fh); // it's not specified, let's output put it to the browser } else { // send an xml content-type to the browser so they know header("Content-type: text/xml"); // echo the feed to the browser echo $feed; } } } /* sample code START */ // make a new instantation of the class $rss = new rss; // give the values to the feed maker $feed = $rss->feed_make($channel_vars, $item_vars); // output the generated feed to the client $rss->output($feed); /* sample code END */ ?>