public static function array_to_xml($array, &$xml)
	{
		foreach($array as $key => $value) {
			if(is_array($value)) {
				if(!is_numeric($key)){
					$subnode = $xml->addChild("$key");
					self::array_to_xml($value, $subnode);
				} elseif ($key == 0) {
					self::array_to_xml($value, $xml);
				} else {
					$name = $xml->getName();
					$subnode = $xml->xpath("..")[0]->addChild("$name");
					self::array_to_xml($value, $subnode);
				}
			} else {
				$xml->addChild("$key","$value");
			}
		}
	}
public static function array_to_xml($array, &$xml)
	{
		foreach($array as $key => $value) {
			if(is_array($value)) {
				if(!is_numeric($key)){
					$subnode = $xml->addChild("$key");
					self::array_to_xml($value, $subnode);
				} elseif ($key == 0) {
					self::array_to_xml($value, $xml);
				} else {
					$name = $xml->getName();
					$subnode = $xml->xpath("..")[0]->addChild("$name");
					self::array_to_xml($value, $subnode);
				}
			} else {
				$xml->addChild("$key","$value");
			}
		}
	}
public static function array_to_xml ( $ array , & $ xml ) { foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { if ( ! is_numeric ( $ key ) ) { $ subnode = $ xml -> addChild ( "$key" ) ; self :: array_to_xml ( $ value , $ subnode ) ; } elseif ( $ key == 0 ) { self :: array_to_xml ( $ value , $ xml ) ; } else { $ name = $ xml -> getName ( ) ; $ subnode = $ xml -> xpath ( ".." ) [ 0 ] -> addChild ( "$name" ) ; self :: array_to_xml ( $ value , $ subnode ) ; } } else { $ xml -> addChild ( "$key" , "$value" ) ; } } }
Helper function to convert an array to XML

@param  array $array
@param  SimpleXMLElement $xml
@return string
Helper function to convert an array to XML