Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $xmlstr = <<<XML
- <?xml version='1.0' standalone='yes'?>
- <media:group>
- <media:content url="http://www.url.com" bitrate="450" width="320" duration="32" />
- <media:content url="http://www.url.com" bitrate="212" width="320" duration="32" />
- </media:group>
- XML;
- $data = new SimpleXMLElement($xmlstr);
- $result = array();
- foreach ($data->content as $entry){
- $subResult = array();
- $attribute = $entry->attributes();
- foreach ($attribute as $key => $value){
- $subResult[(string)$key] = (string)$value;
- }
- $result[] = $subResult;
- }
- var_dump($result);
- /*
- user@host ~ $ php test.php
- array(2) {
- [0]=>
- array(4) {
- ["url"]=>
- string(18) "http://www.url.com"
- ["bitrate"]=>
- string(3) "450"
- ["width"]=>
- string(3) "320"
- ["duration"]=>
- string(2) "32"
- }
- [1]=>
- array(4) {
- ["url"]=>
- string(18) "http://www.url.com"
- ["bitrate"]=>
- string(3) "212"
- ["width"]=>
- string(3) "320"
- ["duration"]=>
- string(2) "32"
- }
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement