I want to export an array to XML file in PHP:
$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);
The data is exported, but the values don't contain Polish characters such as: ń, ś, ł, ó etc. How to fix this? Instead of correct characters, I have: ś ń ę