PHP code example of utlime / php-rss-writer

1. Go to this page and download the library: Download utlime/php-rss-writer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

utlime / php-rss-writer example snippets




_iterator = function ($prefix) {
    for ($i = 0; $i < 3; $i++) {
        $item = new \Utlime\RSS\Item();

        $item->setTitle($prefix . ' title' . $i);

        yield $item;
    }
};

$channel_iterator = function () use ($item_iterator) {
    for ($i = 0; $i < 2; $i++) {
        $channel = new \Utlime\RSS\Channel('title' . $i, 'link' . $i, 'description' . $i);

        $channel->setItems($item_iterator('channel' . $i));

        yield $channel;
    }
};

$output = function ($string) {
    echo $string . "\r\n";
};

$rss = new \Utlime\RSS\RSS();
$rss->setChannels($channel_iterator());

$writer = new Utlime\RSS\Writer($output);
$writer->write($rss);