Hi Frank,

please open a bugreport about this issue. This would start the internal
process of verifying this.

-- Marco

On Dec 7, 2007 11:09 PM, Frank M. Kromann <[EMAIL PROTECTED]> wrote:

> Hello Everyon,
>
> Casting a SimpleXML object to an array gives different results in PHP
> 5.2.5 and PHP 5.3-dev.
>
> Source:
>
> $xml = simplexml_load_file("sample.xml");
>
> foreach($xml->column as $column) {
>    var_dump($column);
>    var_dump((array)$column);
> }
>
> sample.xml
>
> ?xml version="1.0"?>
> <cpdata>
>    <column name="ENTERTAINMENT">
>        <module>cv</module>
>        <module>entsimp</module>
>    </column>
>    <column name="SEAT CONTROL">
>        <module>pp</module>
>        <module>sc</module>
>    </column>
> </cpdata>
>
> PHP 5.2 output:
> object(SimpleXMLElement)#4 (2) {
>  ["@attributes"]=>
>  array(1) {
>    ["name"]=>
>    string(13) "ENTERTAINMENT"
>  }
>  ["module"]=>
>  array(2) {
>    [0]=>
>    string(2) "cv"
>    [1]=>
>    string(7) "entsimp"
>  }
> }
> array(2) {
>  ["@attributes"]=>
>  array(1) {
>    ["name"]=>
>    string(13) "ENTERTAINMENT"
>  }
>  ["module"]=>
>  array(2) {
>    [0]=>
>    string(2) "cv"
>    [1]=>
>    string(7) "entsimp"
>  }
> }
> object(SimpleXMLElement)#5 (2) {
>  ["@attributes"]=>
>  array(1) {
>    ["name"]=>
>    string(12) "SEAT CONTROL"
>  }
>  ["module"]=>
>  array(2) {
>    [0]=>
>    string(2) "pp"
>    [1]=>
>    string(2) "sc"
>  }
> }
> array(2) {
>  ["@attributes"]=>
>  array(1) {
>    ["name"]=>
>    string(12) "SEAT CONTROL"
>  }
>  ["module"]=>
>  array(2) {
>    [0]=>
>    string(2) "pp"
>    [1]=>
>    string(2) "sc"
>  }
> }
>
> PHP 5.3 output:
>
> object(SimpleXMLElement)#4 (2) {
>  ["@attributes"]=>
>  array(1) {
>    ["name"]=>
>    string(13) "ENTERTAINMENT"
>  }
>  ["module"]=>
>  array(2) {
>    [0]=>
>    string(2) "cv"
>    [1]=>
>    string(7) "entsimp"
>  }
> }
> array(1) {
>  ["module"]=>
>  array(2) {
>    [0]=>
>    string(2) "cv"
>    [1]=>
>    string(7) "entsimp"
>  }
> }
> object(SimpleXMLElement)#5 (2) {
>  ["@attributes"]=>
>  array(1) {
>    ["name"]=>
>    string(12) "SEAT CONTROL"
>  }
>  ["module"]=>
>  array(2) {
>    [0]=>
>    string(2) "pp"
>    [1]=>
>    string(2) "sc"
>  }
> }
> array(1) {
>  ["module"]=>
>  array(2) {
>    [0]=>
>    string(2) "pp"
>    [1]=>
>    string(2) "sc"
>  }
> }
>
> Not that the attributes are gone when SimpleXML objects are converted in
> PHP 5.3. Is this a bug or a feature change?
>
> - Frank
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Marco Kaiser

Reply via email to