【发布时间】:2021-05-23 12:03:17
【问题描述】:
我想在 PHP 中将数组导出到 XML 文件:
$fxml = fopen('file.xml', 'w');
$xml = new SimpleXMLElement('<postal_codes/>');
$rows = $db->query('SELECT * FROM postal_codes ORDER BY ID');
foreach ($rows as $row) {
if ($provinces[$row['region']] == 'test') {
$place = $xml->addChild('place');
foreach($fields as $key => $val) {
$place->addChild($val, $row[$val]);
}
}
}
fwrite($fxml, $xml->asXML());
fclose($fxml);
数据已导出,但值不包含波兰语字符,例如:ń、ś、ł、ó 等。如何解决此问题?而不是正确的字符,我有:&#x15B; &#x144; &#x119;
【问题讨论】: