php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30391 is_array() does not work on SimpleXMLElement
Submitted: 2004-10-11 09:13 UTC Modified: 2004-10-11 20:11 UTC
From: sebastian@php.net Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: 5CVS-2004-10-11 (dev) OS: Irrelevant
Private report: No CVE-ID: None
 [2004-10-11 09:13 UTC] 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"
  }
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-11 20:11 UTC] iliaa@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 12:01:31 2024 UTC