Skip to content

Instantly share code, notes, and snippets.

View cdowebcast's full-sized avatar
🏠
Working from home

CDOWEBCAST cdowebcast

🏠
Working from home
View GitHub Profile
@cdowebcast
cdowebcast / gist:70413e3ffe779c6c3f9d
Created January 7, 2016 05:57 — forked from supermethod/gist:913394
Convert a PHP array into XML file using SimpleXML
class ArrayToXML
{
/**
* The main function for converting to an XML document.
* Pass in a multi dimensional array and this recrusively loops through and builds up an XML document.
* Based on: http://snipplr.com/view/3491/convert-php-array-to-xml-or-simple-xml-object-if-you-wish/
*
* @param array $data
* @param string $rootNodeName - what you want the root node to be - defaultsto data.
* @param SimpleXMLElement $xml - should only be used recursively