Created
December 8, 2010 18:01
-
-
Save mach3/733646 to your computer and use it in GitHub Desktop.
Create association array from xml, usin domdocument.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// for example, from RSS | |
$dom = DOMDocument::loadXML( $string_stored_xml ); | |
$entries = array(); | |
foreach( $dom->getElementsByTagname("item") as $item ){ | |
$entry = array(); | |
foreach( $item->childNodes as $node ){ | |
if( $node->nodeType === 1 ){ | |
$entry[ $node->nodeName ] = $node->nodeValue; | |
} | |
} | |
array_push( $entries, $entry ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment