note 101916 deleted from class.simplexmliterator by danbrown

From: Date: Tue, 18 Jan 2011 14:31:13 +0000
Subject: note 101916 deleted from class.simplexmliterator by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-175859@lists.php.net to get a copy of this message
Note Submitter: marcvangend ---- Thanks ratfactor. Here is a slightly modified version of your sxiToArray function which supports attributes. <?php function sxiToArray($sxi) { $a = array(); for ($sxi->rewind(); $sxi->valid(); $sxi->next()) { if (!array_key_exists($sxi->key(), $a)) { $a[$sxi->key()] = array(); } if ($sxi->hasChildren()) { $a[$sxi->key()][] = sxiToArray($sxi->current()); } else { $attr = array(); foreach ($sxi->current()->attributes() as $key => $value) { $attr[$key] = strval($value); } $a[$sxi->key()][] = array( '@value' => strval($sxi->current()), '@attributes' => $attr, ); } } return $a; } ?>

« previous php.notes (#175859) next »