PHPackages                             openprunus/php-xml-array - 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. openprunus/php-xml-array

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

openprunus/php-xml-array
========================

PHP lib for convert array to xml

v0.3.0(8y ago)017LGPL-3.0PHPPHP &gt;=5.6.0

Since May 6Pushed 8y ago1 watchersCompare

[ Source](https://github.com/OpenPrunus/php-xml-array)[ Packagist](https://packagist.org/packages/openprunus/php-xml-array)[ RSS](/packages/openprunus-php-xml-array/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (1)Versions (8)Used By (0)

PHP XML Array library
=====================

[](#php-xml-array-library)

This library convert an array to an XML DOM.

Add to your composer.json in your project
-----------------------------------------

[](#add-to-your-composerjson-in-your-project)

```

composer require openprunus/php-xml-array

```

Usage
-----

[](#usage)

### Code example

[](#code-example)

```
use \PhpXmlArray\XML;

$array = [
    "Root" => [
        [
            "Level1" => "value"
        ],
        [
            "Level1" => [
                [
                    "Level2" => "Level 2 value"
                ],
                [
                    "Level2" => [
                        "_attributes" => [
                            "attrbidule" => "toto"
                        ],
                        "_value" => "value de Level 2"
                    ]
                ],
                "AutreBalise" => "valeur"
            ]
        ],
        [
            "Level1" => [
                "_attributes" => [
                    "attrLevel1" => "titi"
                ],
                "_value" => "value"
            ]
        ]
    ]
];

$xmlInstance = new Xml();

// For unformatted XML
$unformattedConvertedXmlToArray = $xmlInstance->xmlFromArray($array);

// For formatted XML
$formattedConvertedXmlToArray = $xmlInstance->xmlFromArray($array, true);
```

### Results

[](#results)

```
$unformattedConvertedXmlToArray =

valueLevel 2 valuevalue de Level 2valeurvalue

$formattedConvertedXmlToArray =

  value

    Level 2 value
    value de Level 2
    valeur

  value

```

Others array examples
---------------------

[](#others-array-examples)

```
$array1 = [
    "Name" => "Doe",
    "FirstName" => "John",
    "Age" => 30
];

/*
Doe
John
30
*/

$array2 = [
    "Root" => [
        "Name" => "Doe",
        "FirstNames" => [
            "_attributes" => [
                    "foo" => "bar"
            ],
            "_value" => [
                ["FirstName" => "Toto"],
                ["FirstName" => "Titi"],
                ["FirstName" => "Tata"]
            ]
        ],
        "Ages" => [
            "Age1" => 30,
            "Age2" => 31,
            "Age3" => 32
        ]
    ]
];
/*

    Doe

        Toto
        Titi
        Tata
     [
        "_attributes" => [
            "test" => "value"
        ],
        "_value" => [
            "Level1" => [
                "Level2" => [
                    "Level3" => "test"
                ]
            ]
        ]
    ]
];

/*

            test

*/

$array4 = [
    "Root" => [
        "Alone"
    ]
];

/*

*/
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 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 ~1 days

Total

7

Last Release

2925d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e42cf0329c6116ec5530416e67a5a1a15fac6d1221fdce41f74927c6e6cbf258?d=identicon)[OpenPrunus](/maintainers/OpenPrunus)

---

Top Contributors

[![OpenPrunus](https://avatars.githubusercontent.com/u/8170677?v=4)](https://github.com/OpenPrunus "OpenPrunus (18 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/openprunus-php-xml-array/health.svg)

```
[![Health](https://phpackages.com/badges/openprunus-php-xml-array/health.svg)](https://phpackages.com/packages/openprunus-php-xml-array)
```

###  Alternatives

[hcodes/server_yametrika

Server-side tracking of visitors using Yandex.Metrica

7220.2k](/packages/hcodes-server-yametrika)[axllent/silverstripe-trailing-slash

Ensure that a single trailing slash is always added to the URL

11182.6k5](/packages/axllent-silverstripe-trailing-slash)[yeesoft/yii2-comments

Comments Module For Yii2 Framework

227.8k2](/packages/yeesoft-yii2-comments)

PHPackages © 2026

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