PHPackages                             rafrsr/lib-array2xml - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. rafrsr/lib-array2xml

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

rafrsr/lib-array2xml
====================

Array2XML conversion library

v2.0.1(5mo ago)237.4k↓23.3%[2 issues](https://github.com/rafrsr/lib-array2xml/issues)1MITPHPPHP &gt;=8.1CI failing

Since Jun 24Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/rafrsr/lib-array2xml)[ Packagist](https://packagist.org/packages/rafrsr/lib-array2xml)[ RSS](/packages/rafrsr-lib-array2xml/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (1)Versions (4)Used By (1)

lib-array2xml
=============

[](#lib-array2xml)

[![Build Status](https://camo.githubusercontent.com/613e40207125be7a49a1bcf9bf6c5328a823d757df09f45749ea463e6dc4ea9a/68747470733a2f2f7472617669732d63692e6f72672f7261667273722f6c69622d617272617932786d6c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/rafrsr/lib-array2xml)[![Coverage Status](https://camo.githubusercontent.com/63b66aab5bf274f667949ba7220815418b26a268a0b329e07a2147a5f1062228/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7261667273722f6c69622d617272617932786d6c2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/rafrsr/lib-array2xml?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/b657cbf96acdcf9c1cd03fb36b124f8fb95b215b3b9beded0911a703ecd541f2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7261667273722f6c69622d617272617932786d6c2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/rafrsr/lib-array2xml/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/27c606586ab41659570ba557443e9168af713368f3d03b77868c83fba75089e2/68747470733a2f2f706f7365722e707567782e6f72672f7261667273722f6c69622d617272617932786d6c2f76657273696f6e)](https://packagist.org/packages/rafrsr/lib-array2xml)[![Latest Unstable Version](https://camo.githubusercontent.com/939aa166337393af470c45f17dae63fd3dca1b13c5419c4f40c0fd2062ad015e/68747470733a2f2f706f7365722e707567782e6f72672f7261667273722f6c69622d617272617932786d6c2f762f756e737461626c65)](//packagist.org/packages/rafrsr/lib-array2xml)[![Total Downloads](https://camo.githubusercontent.com/60042a6392f22877fe3fedf253d749aa06408a9793236a843aa9e4211988b13e/68747470733a2f2f706f7365722e707567782e6f72672f7261667273722f6c69622d617272617932786d6c2f646f776e6c6f616473)](https://packagist.org/packages/rafrsr/lib-array2xml)[![License](https://camo.githubusercontent.com/a69ad742938a6ba10d9a38109f6171899d696af4a0c2714ee2c1460ba70652bc/68747470733a2f2f706f7365722e707567782e6f72672f7261667273722f6c69622d617272617932786d6c2f6c6963656e7365)](https://packagist.org/packages/rafrsr/lib-array2xml)

XML2Array is a class to convert XML to an array in PHP. It returns an array which can be converted back to XML using the Array2XML class.

It can take a string XML as input or an object of type DOMDocument.

Installation
------------

[](#installation)

1. [Install composer](https://getcomposer.org/download/)
2. Execute: `composer require rafrsr/lib-array2xml`

Usage
-----

[](#usage)

The usage is pretty simple. You have to include the class file in your code and call the following function.

```
$array = XML2Array::createArray($xml);
print_r($array);
```

### Example

[](#example)

The Following XML:

```

    PHP: Behind the Parser

        Ms. Coder
        Onlivia Actora

        Mr. Coder
        El ActÓr

    So, this language. It's like, a programming language. Or is it a scripting language?
All is revealed in this thrilling horror spoof of a documentary.]]>

      PHP solves all my web problems

    7
    5

```

will generate the following output:

```
array (
    'movies' => array (
        'movie' => array (
            'title' => 'PHP: Behind the Parser',
            'characters' => array (
                'character' => array (
                    0 => array (
                        'name' => 'Ms. Coder',
                        'actor' => 'Onlivia Actora',
                    ),
                    1 => array (
                        'name' => 'Mr. Coder',
                        'actor' => 'El ActÓr',
                    ),
                ),
            ),
            'plot' => array (
                '@cdata' => 'So, this language. It\'s like, a programming language. Or is it a scripting language?
All is revealed in this thrilling horror spoof of a documentary.',
            ),
            'great-lines' => array (
                'line' => 'PHP solves all my web problems',
            ),
            'rating' => array (
                0 => array (
                    '@value' => '7',
                    '@attributes' => array (
                        'type' => 'thumbs',
                    ),
                ),
                1 => array (
                    '@value' => '5',
                    '@attributes' => array (
                        'type' => 'stars',
                    ),
                ),
            ),
        ),
        '@attributes' => array (
            'type' => 'documentary',
        ),
    ),
)
```

References
----------

[](#references)

This class is based on with some minor bug fixed and support for php7

Copyright
---------

[](#copyright)

This project is licensed under the [MIT license](LICENSE).

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance50

Moderate activity, may be stable

Popularity30

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1747 days

Total

3

Last Release

168d ago

Major Versions

v1.0.1 → v2.0.12026-01-16

PHP version history (2 changes)v1.0.0PHP &gt;=5.4

v2.0.1PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/4a2b6fe4cdd0f7970b78769f972884c46759925b8bfe9814e47a2799b6439de7?d=identicon)[rafrsr](/maintainers/rafrsr)

---

Top Contributors

[![rafrsr](https://avatars.githubusercontent.com/u/7094012?v=4)](https://github.com/rafrsr "rafrsr (7 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rafrsr-lib-array2xml/health.svg)

```
[![Health](https://phpackages.com/badges/rafrsr-lib-array2xml/health.svg)](https://phpackages.com/packages/rafrsr-lib-array2xml)
```

###  Alternatives

[symfony/thanks

Encourages sending ⭐ and 💵 to fellow PHP package maintainers (not limited to Symfony components)!

8.1k16.3M300](/packages/symfony-thanks)[laminas/laminas-component-installer

Composer plugin for injecting modules and configuration providers into application configuration

304.4M108](/packages/laminas-laminas-component-installer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
