note 118109 added to class.simplexmliterator
| From: | php-lover at live dot com | Date: | Mon, 05 Oct 2015 21:50:36 +0000 |
| Subject: | note 118109 added to class.simplexmliterator | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203911@lists.php.net to get a copy of this message | ||
Function to extract SimpleXMLElement data to array.
function extract($sxe = null) {
if (!$sxe instanceOf SimpleXMLElement)
return array();
$extract = array();
foreach ($sxe->children() as $key => $value) {
if (array_key_exists($key, $extract)) {
if (!isset($extract[$key][0])) {
$tmp_extract = $extract[$key];
$extract[$key] = array();
$extract[$key][0] = $tmp_extract;
} else
$extract[$key] = (array) $extract[$key];
}
if ($value->count()) {
if (isset($extract[$key]) && is_array($extract[$key]))
$extract[$key][] = $this->extract($value);
else
$extract[$key] = $this->extract($value);
} else {
if (isset($extract[$key]) && is_array($extract[$key]))
$extract[$key][] = empty(strval($value)) ? null : strval($value);
else
$extract[$key] = empty(strval($value)) ? null : strval($value);
}
}
return $extract;
}
----
Server IP: 72.52.91.14
Probable Submitter: 41.136.99.147
----
Manual Page -- http://php.net/manual/en/class.simplexmliterator.php
Edit -- https://master.php.net/note/edit/118109
Del: integrated -- https://master.php.net/note/delete/118109/integrated
Del: useless -- https://master.php.net/note/delete/118109/useless
Del: bad code -- https://master.php.net/note/delete/118109/bad+code
Del: spam -- https://master.php.net/note/delete/118109/spam
Del: non-english -- https://master.php.net/note/delete/118109/non-english
Del: in docs -- https://master.php.net/note/delete/118109/in+docs
Del: other reasons-- https://master.php.net/note/delete/118109
Reject -- https://master.php.net/note/reject/118109
Search -- https://master.php.net/manage/user-notes.php