この指定された配列を変換したい
array(
'podcast' => array(
(int) 0 => array(
'Podcast' => array(
'id' => '2',
'xmlurl' => 'http://test2.com'
)
),
(int) 1 => array(
'Podcast' => array(
'id' => '4',
'xmlurl' => 'http://test4.com'
)
)
)
)
CakePHP 2.3.6 を使用してこの文字列に変換します。
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<opml version="2.0">
<head></head>
<body>
<outline xmlUrl="http://test2.com" />
<outline xmlUrl="http://test4.com" />
</body>
</opml>
どうすればいいですか?ここに Docがあることは知っていますが、助けていただければ幸いです。
これは私がこれまでに持っているものです:
$new = array();
foreach($podcasts as $p):
$pod['xmlurl'] = $p['Podcast']['xmlurl'];
endforeach;
$new['opml']['body']['outline'][]=$pod;
debug($new);
$xmlObject = Xml::fromArray($new);
$xmlString = $xmlObject->asXML();
debug($xmlString);
出力debug($xmlString)
:
'<?xml version="1.0" encoding="UTF-8"?>
<opml>
<body>
<outline>
<xmlurl>http://test1.com</xmlurl>
</outline>
</body>
</opml>'