note 40089 deleted from ref.simplexml by kennyt
| From: | kennyt@php.net | Date: | Sun, 18 Jul 2004 16:58:36 +0000 |
| Subject: | note 40089 deleted from ref.simplexml by kennyt | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-73493@lists.php.net to get a copy of this message | ||
Note Submitter: jwhite@theideabasket.com
----
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.