PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of emnu   Array2XML   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example on howto use the class
Class: Array2XML
Generate an XML document from array data
Author: By
Last change:
Date: 16 years ago
Size: 1,242 bytes
 

Contents

Class file image Download
<?php

// array sample
$sample = Array
(
   
0 => Array
        (
           
'Post' => Array
                (
                   
'id' => 1,
                   
'title' => 'The title',
                   
'body' => 'This is the post body.',
                   
'created' => '2008-07-28 12:01:06',
                   
'modified' => '',
                )
        ),
   
1 => Array
        (
           
'Post' => Array
                (
                   
'id' => 2,
                   
'title' => 'A title once again',
                   
'body' => 'And the post body follows.',
                   
'created' => '2008-07-28 12:01:06',
                   
'modified' => '',
                    array(
'fdgs'),
                )
        ),
   
2 => Array
        (
           
'Post' => Array
                (
                   
'id' => 3,
                   
'title' => 'Title strikes back',
                   
'body' => 'This is really exciting Not.',
                   
'created' => '2008-07-28 12:01:06',
                   
'modified' => '',
                )
        ),
);

// howto
include ('array2xml.php');

$xml = new arr2xml($sample);
header ("content-type: text/xml");
echo
$xml->get_xml();

?>