这是我的php代码,它应该写一个CSV文件,但输出文件包含无法阅读的字母和符号.我应该怎么做才能让信息用波斯字母书写?
<?php
// Get RSS feed URL from form data
$rss_url = $_POST['rss-url'];
// Create SimpleXMLElement object from RSS feed
$rss = new SimpleXMLElement(file_get_contents($rss_url));
// Open CSV file for writing
$filename = 'rss-data.csv';
$file = fopen($filename, 'w');
// Write header row to CSV file
$header_row = array('Title', 'Description', 'PublicationDate', 'Link', 'Photo');
fputcsv($file, $header_row);
// Loop through RSS feed items
foreach ($rss->channel->item as $item) {
// Extract data from item
$title = mb_convert_encoding((string) $item->title, 'UTF-8', 'ISO-8859-1');
$description = mb_convert_encoding((string) $item->description, 'UTF-8', 'ISO-8859-1');
$pub_date = mb_convert_encoding((string) $item->pubDate, 'UTF-8', 'ISO-8859-1');
$link = mb_convert_encoding((string) $item->link, 'UTF-8', 'ISO-8859-1');
preg_match('/<img.*?src="(.*?)".*?>/is', $description, $matches);
$image = isset($matches[1]) ? $matches[1] : '';
// Write data to CSV file
$data_row = array($title, strip_tags($description), $pub_date, $link, $image);
fputcsv($file, $data_row);
}
// Close CSV file
fclose($file);
// Redirect to index.html
header('Location: index.html');
exit();
?>
我的php代码应该会在其中编写一个包含波斯字母的CSV文件.