How can I determine the character encoding of an RSS feed when displaying it on a website using PHP?

To determine the character encoding of an RSS feed when displaying it on a website using PHP, you can use the PHP function `mb_detect_encoding()` to detect the encoding of the feed. Once you have determined the encoding, you can use the `mb_convert_encoding()` function to convert the feed to the desired encoding before displaying it on your website.

// Fetch the RSS feed
$rss_feed = file_get_contents('https://example.com/rss-feed.xml');

// Detect the character encoding of the feed
$encoding = mb_detect_encoding($rss_feed, 'UTF-8, ISO-8859-1, ISO-8859-15', true);

// Convert the feed to UTF-8 encoding
$rss_feed = mb_convert_encoding($rss_feed, 'UTF-8', $encoding);

// Display the RSS feed on your website
echo $rss_feed;