note 103775 deleted from class.simplexmliterator by danbrown

From: Date: Tue, 03 May 2011 13:41:33 +0000
Subject: note 103775 deleted from class.simplexmliterator by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-179367@lists.php.net to get a copy of this message
Note Submitter: Lars Beck ---- The previous example will also work without a helper function, just define it as a nested one: function parse($str) { function iterate($iter) { foreach($iter as $key=>$val) { if($iter->hasChildren()) { $array[$key][] = call_user_func(__FUNCTION__, $val); } else { $array[$key][] = strval($val); } } return $array; }; return iterate(new SimpleXmlIterator($str)); }

« previous php.notes (#179367) next »