Convert xml to an array
, (*1)
This package provides a very simple class to convert an xml string to an array., (*2)
Inspired by Spatie's array-to-xml ❤️, (*3)
Install
You can install this package via composer., (*4)
``` bash
composer require vyuldashev/xml-to-array, (*5)
## Usage
```php
use Vyuldashev\XmlToArray\XmlToArray;
$xml = '<items>
<good_guy>
<name>Luke Skywalker</name>
<weapon>Lightsaber</weapon>
</good_guy>
<bad_guy>
<name>Sauron</name>
<weapon>Evil Eye</weapon>
</bad_guy>
</items>';
$result = XmlToArray::convert($xml);
After running this piece of code $result
will contain:, (*6)
array:1 [
"items" => array:2 [
"good_guy" => array:2 [
"name" => "Luke Skywalker"
"weapon" => "Lightsaber"
]
"bad_guy" => array:2 [
"name" => "Sauron"
"weapon" => "Evil Eye"
]
]
]