note 68286 added to ref.simplexml

From: Date: Thu, 20 Jul 2006 19:41:13 +0000
Subject: note 68286 added to ref.simplexml
Groups: php.notes 
Request: Send a blank email to php-notes+get-114987@lists.php.net to get a copy of this message
Just a minor modification to Daniel Favire's simplexml2ISOarray function: I added an if-block around the attributes section so you don't get a SimpleXML attributes element along with each attributes array: function simplexml2ISOarray($xml) { if (get_class($xml) == 'SimpleXMLElement') { $attributes = $xml->attributes(); foreach($attributes as $k=>$v) { if ($v) $a[$k] = (string) $v; } $x = $xml; $xml = get_object_vars($xml); } if (is_array($xml)) { if (count($xml) == 0) return (string) $x; // for CDATA foreach($xml as $key=>$value) { if($key != '@attributes') { $r[$key] = simplexml2ISOarray($value); if ( !is_array( $r[$key] ) ) $r[$key] = utf8_decode( $r[$key] ); } } if (isset($a)) $r['@'] = $a; // Attributes return $r; } return (string) $xml; } ---- Server IP: 216.194.113.175 Probable Submitter: 206.126.9.90 ---- 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/68286 Del: integrated -- http://master.php.net/note/delete/68286/integrated Del: useless -- http://master.php.net/note/delete/68286/useless Del: bad code -- http://master.php.net/note/delete/68286/bad+code Del: spam -- http://master.php.net/note/delete/68286/spam Del: non-english -- http://master.php.net/note/delete/68286/non-english Del: in docs -- http://master.php.net/note/delete/68286/in+docs Del: other reasons-- http://master.php.net/note/delete/68286 Reject -- http://master.php.net/note/reject/68286 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#114987) next »