#30391 [Opn->Bgs]: is_array() does not work on SimpleXMLElement
| From: | iliaa@php.net | Date: | Mon, 11 Oct 2004 18:11:54 +0000 |
| Subject: | #30391 [Opn->Bgs]: is_array() does not work on SimpleXMLElement | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-67427@lists.php.net to get a copy of this message | ||
ID: 30391
Updated by: iliaa@php.net
Reported By: sebastian@php.net
-Status: Open
+Status: Bogus
Bug Type: SimpleXML related
Operating System: Irrelevant
PHP Version: 5CVS-2004-10-11 (dev)
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
SimpleXML creates dynamic objects, array functions will not work on
these.
Previous Comments:
------------------------------------------------------------------------
[2004-10-11 09:13:22] sebastian@php.net
Description:
------------
is_array() does not work on member arrays of SimpleXMLElement objects.
Reproduce code:
---------------
<?php
$foo = simplexml_load_string(
'<?xml version="1.0" encoding="iso-8859-1" ?>
<foo>
<bar>
<barbara>barbara</barbara>
</bar>
<bar>
<barbara>barbara</barbara>
<barbara>barbara</barbara>
</bar>
</foo>');
foreach ($foo->bar as $bar) {
var_dump(is_array($bar->barbara));
var_dump($bar);
}
?>
Expected result:
----------------
bool(false)
object(SimpleXMLElement)#4 (1) {
["barbara"]=>
string(7) "barbara"
}
bool(true)
object(SimpleXMLElement)#5 (1) {
["barbara"]=>
array(2) {
[0]=>
string(7) "barbara"
[1]=>
string(7) "barbara"
}
}
Actual result:
--------------
bool(false)
object(SimpleXMLElement)#4 (1) {
["barbara"]=>
string(7) "barbara"
}
bool(false)
object(SimpleXMLElement)#5 (1) {
["barbara"]=>
array(2) {
[0]=>
string(7) "barbara"
[1]=>
string(7) "barbara"
}
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30391&edit=1