Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function convertToXML($results, &$xml_user_info){
foreach($results as $key => $value){
if(is_array($results)){
$subnode = $xml_user_info->addChild($key);
foreach ($value as $k=>$v) {
$xml_user_info->addChild("$k", $v);
}
}else{
$xml_user_info->addChild("$key",htmlspecialchars("$value"));
}
}
return $xml_user_info->asXML();
}
$xml_user_info = new SimpleXMLElement('<?xml version=\”1.0\”?><root></root>');
$xml_content = convertToXML($results,$xml_user_info);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment