Home >Backend Development >PHP Tutorial >Solve the problem of Chinese character encoding in xml file generated by php array_PHP tutorial
Chinese characters often bring us some troubles in PHP applications. Today when I found an array on the Internet and converted it into xml, I found that the Chinese characters were empty. Later, I gged Guan Tian and got better results. The following is the same as Share it with everyone.
When converting php array to xml, we learned how to write it in php
The code is as follows
|
Copy code
|
||||||||
} foreach($array as $key => $value){ If(is_array($value)){ array2xml($value, $xml->addChild($key));}else{ $xml->addChild($key, $value);
} |
The code is as follows | Copy code | ||||
function array2xml($array, $xml = false){
If($xml === false){
$xml = new SimpleXMLElement('
|