Skip to content

Commit d9104a9

Browse files
committed
IHF: array_to_xml readme info added.
1 parent 949dd39 commit d9104a9

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Provides Laravel-specific and pure PHP helper functions.
6464
6565
- [Xml](#xml)
6666
- [xml_to_array](#xml_to_array)
67+
- [array_to_xml](#array_to_xml)
6768
6869
## Array
6970
@@ -379,3 +380,34 @@ $array = xml_to_array('<?xml version="1.0" encoding="UTF-8"?>
379380
```
380381
381382
Alternatively, you can pass an instance of `SimpleXMLElement` object, to get the same results.
383+
384+
#### `array_to_xml()`
385+
386+
Converts array to xml string using [spatie/array-to-xml](https://github.com/spatie/array-to-xml) package:
387+
388+
```php
389+
$array = [
390+
'Good guy' => [
391+
'name' => 'Luke Skywalker',
392+
'weapon' => 'Lightsaber',
393+
],
394+
'Bad guy' => [
395+
'name' => 'Sauron',
396+
'weapon' => 'Evil Eye',
397+
]
398+
];
399+
400+
$xml = array_to_xml($array);
401+
402+
// <?xml version="1.0"?>
403+
// <root>
404+
// <Good_guy>
405+
// <name>Luke Skywalker</name>
406+
// <weapon>Lightsaber</weapon>
407+
// </Good_guy>
408+
// <Bad_guy>
409+
// <name>Sauron</name>
410+
// <weapon>Evil Eye</weapon>
411+
// </Bad_guy>
412+
// </root>
413+
```

0 commit comments

Comments
 (0)