note 108035 added to book.simplexml
| From: | thedoc8786 at gmail dot com | Date: | Fri, 23 Mar 2012 16:19:06 +0000 |
| Subject: | note 108035 added to book.simplexml | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186792@lists.php.net to get a copy of this message | ||
I know it is over-done, but the following is a super-short example of a XML to Array conversion
function (recursive):
<?php
function toArray(SimpleXMLElement $xml) {
$array = (array)$xml;
foreach ( array_slice($array, 0) as $key => $value ) {
if ( $value instanceof SimpleXMLElement ) {
$array[$key] = empty($value) ? NULL : toArray($value);
}
}
return $array;
}
----
Server IP: 69.147.83.197
Probable Submitter: 66.208.51.205
----
Manual Page -- http://www.php.net/manual/en/book.simplexml.php
Edit -- https://master.php.net/note/edit/108035
Del: integrated -- https://master.php.net/note/delete/108035/integrated
Del: useless -- https://master.php.net/note/delete/108035/useless
Del: bad code -- https://master.php.net/note/delete/108035/bad+code
Del: spam -- https://master.php.net/note/delete/108035/spam
Del: non-english -- https://master.php.net/note/delete/108035/non-english
Del: in docs -- https://master.php.net/note/delete/108035/in+docs
Del: other reasons-- https://master.php.net/note/delete/108035
Reject -- https://master.php.net/note/reject/108035
Search -- https://master.php.net/manage/user-notes.php