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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sebastian@php.net
New email:
PHP Version: OS:

 

 [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-2022 The PHP Group
All rights reserved.
Last updated: Wed Nov 30 04:05:54 2022 UTC