note 112038 added to ref.simplexml

From: Date: Thu, 25 Apr 2013 15:00:22 +0000
Subject: note 112038 added to ref.simplexml
Groups: php.notes 
Request: Send a blank email to php-notes+get-194622@lists.php.net to get a copy of this message
This is a slight adjustment to http://www.php.net/manual/en/ref.simplexml.php#103617 's function. The function given by them would convert a simpleXML to an array but only at the highest level. Once you add the is_array check with the is_object it should convert each level to an array (well it did for me through 3 levels). function simpleXmlObjectToArray ( $xmlObject, $out = array () ) { foreach ( (array) $xmlObject as $index => $node ) $out[$index] = ( is_object ( $node ) || is_array($node) ) ? simpleXmlObjectToArray ( $node ) : $node; return $out; } Happy Coding! ---- Server IP: 69.147.83.199 Probable Submitter: 98.191.61.25 ---- Manual Page -- http://php.net/manual/en/ref.simplexml.php Edit -- https://master.php.net/note/edit/112038 Del: integrated -- https://master.php.net/note/delete/112038/integrated Del: useless -- https://master.php.net/note/delete/112038/useless Del: bad code -- https://master.php.net/note/delete/112038/bad+code Del: spam -- https://master.php.net/note/delete/112038/spam Del: non-english -- https://master.php.net/note/delete/112038/non-english Del: in docs -- https://master.php.net/note/delete/112038/in+docs Del: other reasons-- https://master.php.net/note/delete/112038 Reject -- https://master.php.net/note/reject/112038 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#194622) next »