We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 00e2725 commit ffc33f2Copy full SHA for ffc33f2
src/Traits/Parser.php
@@ -13,15 +13,15 @@
13
14
trait Parser
15
{
16
- function arrayToXml( SimpleXMLElement $object, array $data )
+ function arrayToXml( SimpleXMLElement $object, array $data, $parent_key = null )
17
18
foreach ( $data as $key => $value ) {
19
- if ( is_numeric( $key ) ) {
20
- $key = str_singular( $key );
+ if ( is_numeric( $key ) && !is_null( $parent_key ) ) {
+ $key = str_singular( $parent_key );
21
}
22
if ( is_array( $value ) ) {
23
$new_object = $object->addChild( $key );
24
- $this->arrayToXml( $new_object, $value );
+ $this->arrayToXml( $new_object, $value, $key );
25
} else {
26
$object->addChild( $key, $value );
27
0 commit comments