Skip to content

Instantly share code, notes, and snippets.

@saasindustries
Created January 18, 2021 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saasindustries/cb8fd3bd0c577ba8854cac37e1bf11e1 to your computer and use it in GitHub Desktop.
Save saasindustries/cb8fd3bd0c577ba8854cac37e1bf11e1 to your computer and use it in GitHub Desktop.
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