I'm trying to convert a multidimensional array to an XML file with SimpleXML. I followed instructions from this post: https://stackoverflow.com/a/5965940/3169412 with these edits: http://pastebin.com/pYuXQWee but I can't get a correct result.
array used:
$array = 
array(
'name' => 'xxx',
'chapter' => array(
    array(
    'title' => 'yyy',
    'slide' => 
        array(
        'header' => array('zzz','aaa'),
        'paragraph' => array('bbb','ccc')
        ),
        array(
            'header' => array('ddd'),
            'paragraph' => array('eee')
        )
    ),
    array(
        'title' => 'fff',
        'slide' => array(
            'header' => array('ggg'),
            'paragraph' => array('hhh')
        )
    )
    )
);
Preferred (needed) XML output: http://pastebin.com/HWWeDehK
I tried using different approaches to get the right nodes on the right place, but they all seemed to fail. Closest I got was using array_keys($values), but then I got a lot of double nodes, or nodes on the wrong place.
XMLresult right now: http://pastebin.com/L8LL5VVe
 
     
     
    