Skip to content

Commit e5e98c0

Browse files
committed
IHF: array_to_xml helper added.
1 parent cea313b commit e5e98c0

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"illuminate/support": "^5.1",
1515
"symfony/finder": "^2.7|^3.0",
1616
"symfony/process": "^2.7|^3.0",
17-
"symfony/var-dumper": "^2.7|^3.0"
17+
"symfony/var-dumper": "^2.7|^3.0",
18+
"spatie/array-to-xml": "^2.2"
1819
},
1920
"require-dev": {
2021
"phpunit/phpunit": "^5.0",

composer.lock

Lines changed: 49 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/xml.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use Spatie\ArrayToXml\ArrayToXml;
4+
35
if (!function_exists('xml_to_array')) {
46
function xml_to_array($xml)
57
{
@@ -8,3 +10,10 @@ function xml_to_array($xml)
810
return json_decode(json_encode($xml), true);
911
}
1012
}
13+
14+
if (!function_exists('array_to_xml')) {
15+
function array_to_xml(array $array, $rootElementName = '', $replaceSpacesByUnderScoresInKeyNames = true)
16+
{
17+
return ArrayToXml::convert($array, $rootElementName, $replaceSpacesByUnderScoresInKeyNames);
18+
}
19+
}

0 commit comments

Comments
 (0)