Location: PHPKode > scripts > Simple XML Array Helper > array2xml.php
<?php
require 'SimpleXMLArrayHelper.php';
$xml = new SimpleXMLArrayHelper('result', array('atr' => 2, 'time' => 'UTz_' . time()));
$array = array(
    'meta' => array(
        '@generated' => 0.002,
        array(
            array(
                'title' => array(
                    'value' => 'Test title'
                ),
                'keywords' => array(
                    'value' => 'Test keywords'
                ),
                'description' => array(
                    'value' => 'Test description'
                )
            )
        )
    ),
    'collection' => array(
        array(
            array(
                'cd' => array(
                    '@id' => 12451,
                    array(
                        array(
                            'artist' => array(
                                'value' => 'Ben Harper'
                            )
                        ),
                        array(
                            'year' => array(
                                'value' => 1995
                            )
                        )
                    )
                )
            ),
            array(
                'cd' => array(
                    '@id' => 121,
                    array(
                        array(
                            'artist' => array(
                                'value' => 'Ben Harp2eer'
                            )
                        ),
                        array(
                            'year' => array(
                                'value' => 1975
                            )
                        )
                    )
                )
            )
        )
    )
);
echo $xml->setArray($array)->asXml();
Return current item: Simple XML Array Helper