PHP code example of rafrsr / lib-array2xml

1. Go to this page and download the library: Download rafrsr/lib-array2xml library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rafrsr / lib-array2xml example snippets


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

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',
        ),
    ),
)