note 63583 added to ref.simplexml

From: Date: Fri, 24 Mar 2006 11:24:20 +0000
Subject: note 63583 added to ref.simplexml
Groups: php.notes 
Request: Send a blank email to php-notes+get-106530@lists.php.net to get a copy of this message
Another function that convert SimpleXMLElement to array. I hope this will be useful... <?php /** * Convert SimpleXMLElement object to array * Copyleft GPL license * @author Romain Lalaut 2006 * * @param SimpleXMLElement * @return array */ function simplexml2array(SimpleXMLElement &$xml) { $result = array(); $attributes = $xml->attributes(); foreach($attributes as $aname=>$avalue) $result['@attrs'][$aname] = (string) $avalue; $value = (string) $xml; if($value) $result['@value'] = $value; $children = $xml->children(); foreach($children as $cname=>$cnode) $result[$cname] = simplexml2array($cnode); return $result; } ?> ---- Server IP: 195.221.21.36 Probable Submitter: 82.226.121.167 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/ref.simplexml.php Edit -- http://master.php.net/note/edit/63583 Del: integrated -- http://master.php.net/note/delete/63583/integrated Del: useless -- http://master.php.net/note/delete/63583/useless Del: bad code -- http://master.php.net/note/delete/63583/bad+code Del: spam -- http://master.php.net/note/delete/63583/spam Del: non-english -- http://master.php.net/note/delete/63583/non-english Del: in docs -- http://master.php.net/note/delete/63583/in+docs Del: other reasons-- http://master.php.net/note/delete/63583 Reject -- http://master.php.net/note/reject/63583 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#106530) next »