note 40089 added to ref.simplexml

From: Date: Sat, 21 Feb 2004 09:31:48 +0000
Subject: note 40089 added to ref.simplexml
Groups: php.notes 
Request: Send a blank email to php-notes+get-65478@lists.php.net to get a copy of this message
One very important thing that I've found out (after much fiddling around) is that you have to typecast a SimpleXML variable to a string before assigning it to another variable. For example, if you wanted to add a certain attribute of several XML tags to an array using each tag's contents as the index, you'd have to do this: <?php foreach ($xml->paragraph as $i => $prop) { $propArray[(string)$prop] = (string)$prop['someattribute']; } ?> I guess this makes sense when you read about how the __toString() method works in the Zend Engine 2.0 change notes (http://www.php.net/zend-engine-2.php), but it seems just a wee bit complicated syntactically to me. ---- Manual Page -- http://www.php.net/manual/en/ref.simplexml.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40089 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40089&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40089&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#65478) next »