Mariusz Muszyński 8 rokov pred
rodič
commit
8b89514763
1 zmenil súbory, kde vykonal 5 pridanie a 5 odobranie
  1. 5 5
      SE/se-lib/V.php

+ 5 - 5
SE/se-lib/V.php

@@ -554,13 +554,13 @@ EOF';
 
 
 	public static function arrayToXML($array, $formatOutput = false, $root = "root") {
 	public static function arrayToXML($array, $formatOutput = false, $root = "root") {
 
 
-		function arrayToXML_rec($data, $dom, $node, $parent = null) {
+		$arrayToXML_rec = function($data, $dom, $node, $parent = null) use (&$arrayToXML_rec) {
 			$child = $dom->createElement($node);
 			$child = $dom->createElement($node);
 			if (!$parent) $parent = $dom;
 			if (!$parent) $parent = $dom;
 			if (is_array($data)) {
 			if (is_array($data)) {
 				foreach ($data as $key => $value) {
 				foreach ($data as $key => $value) {
-					if (is_numeric($key)) arrayToXML_rec($value, $dom, $node, $parent);
-					else arrayToXML_rec($value, $dom, $key, $child);
+					if (is_numeric($key)) $arrayToXML_rec($value, $dom, $node, $parent);
+					else $arrayToXML_rec($value, $dom, $key, $child);
 				}
 				}
 			} else {
 			} else {
 				if ($data) {
 				if ($data) {
@@ -569,13 +569,13 @@ EOF';
 				} else $parent->appendChild($child);
 				} else $parent->appendChild($child);
 			}
 			}
 			if ($child->hasChildNodes()) $parent->appendChild($child);
 			if ($child->hasChildNodes()) $parent->appendChild($child);
-		}
+		};
 
 
 		if (!is_array($array)) throw new Exception("First argument need to be an array");
 		if (!is_array($array)) throw new Exception("First argument need to be an array");
 		$dom = new DOMDocument('1.0', 'UTF-8');
 		$dom = new DOMDocument('1.0', 'UTF-8');
 		$dom->preserveWhiteSpace = false;
 		$dom->preserveWhiteSpace = false;
 		$dom->formatOutput = $formatOutput;
 		$dom->formatOutput = $formatOutput;
-		arrayToXML_rec($array, $dom, $root);
+		$arrayToXML_rec($array, $dom, $root);
 		return $dom->saveXML();
 		return $dom->saveXML();
 	}
 	}