php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42571 Method variable array's missing
Submitted: 2007-09-05 20:01 UTC Modified: 2007-09-14 01:00 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: rockerboo at gmail dot com Assigned:
Status: No Feedback Package: SimpleXML related
PHP Version: 5.2.4 OS: CentOS 5
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: rockerboo at gmail dot com
New email:
PHP Version: OS:

 

 [2007-09-05 20:01 UTC] rockerboo at gmail dot com
Description:
------------
I create an SimpleXmlElement, and see if one of the member variable array's in an array, and it says it is not. But I am able to foreach through the array, and when I do, the key states they 2nd parent's key as the key. 

Linux virbdevel.com 2.6.18-8.1.4.el5.028stab035.1 #1 SMP Sat Jun 9 01:43:20 MSD 2007 i686

'./configure' '--with-apxs2=/usr/sbin/apxs' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--libdir=/usr/lib' '--with-libdir=lib' '--with-mysql' '--with-mysqli' '--with-pear' '--with-zlib' '--with-openssl' '--with-png' '--with-jpeg-dir=/usr/lib' '--with-bz2' '--enable-bcmath' '--enable-exif' '--with-fam' '--with-gd' '--enable-gd-native-ttf' '--with-freetype-dir=/usr/lib' '--enable-gd-jis-conv' '--with-imap' '--with-imap-ssl' '--enable-mbstring' '--with-iconv' '--with-mcrypt' '--enable-shmop' '--enable-imap' '--enable-imap-ssl' '--with-kerberos' '--with-xsl' '--with-dom' '--enable-soap' '--enable-simplexml' '--with-mhash' '--with-curl' '--enable-calendar' '--enable-dbx' '--with-xml' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-track-vars' '--enable-trans-sid' '--enable-sockets' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--disable-ffmpeg'

Reproduce code:
---------------
http://pastebin.com/f252f4872

Expected result:
----------------
    
SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [type] => array
        )

    [status] => Array
        (
            [0] => SimpleXMLElement Object
                (
                    [created_at] => Wed Sep 05 18:06:54 +0000 2007
                    [id] => 249403592
                    [text] => Everyone that gets the new iPod Touch automatically receives a iPhone Wannabe t-shirt and decal.
                    [source] => twitterrific
                    [user] => SimpleXMLElement Object
                        (
                            [id] => 5871202
                            [name] => Brad
                            [screen_name] => stillframe
                            [location] => Boston, USA
                            [description] => drunk and in jail for arson
                            [profile_image_url] => http://assets1.twitter.com/system/user/profile_image/5871202/normal/noobbrad_x150.jpg?1187756051
                            [url] => http://stillframe.com
                            [protected] => false
                        )

                )

            [1] => SimpleXMLElement Object
                (
                    [created_at] => Wed Sep 05 18:02:46 +0000 2007
                    [id] => 249393302
                    [text] => iPodTouch? No. iPodBadTouch. Don't touch your iPod that way.
                    [source] => twitterrific
                    [user] => SimpleXMLElement Object
                        (
                            [id] => 5871202
                            [name] => Brad
                            [screen_name] => stillframe
                            [location] => Boston, USA
                            [description] => drunk and in jail for arson
                            [profile_image_url] => http://assets1.twitter.com/system/user/profile_image/5871202/normal/noobbrad_x150.jpg?1187756051
                            [url] => http://stillframe.com
                            [protected] => false
                        )

                )

            [2] => SimpleXMLElement Object
                (
                    [created_at] => Wed Sep 05 17:10:46 +0000 2007
                    [id] => 249255522
                    [text] => Dear coffee, I forgot to say hi this morning. Apple event is kicking off. Expect more neglect.
                    [source] => twitterrific
                    [user] => SimpleXMLElement Object
                        (
                            [id] => 5871202
                            [name] => Brad
                            [screen_name] => stillframe
                            [location] => Boston, USA
                            [description] => drunk and in jail for arson
                            [profile_image_url] => http://assets1.twitter.com/system/user/profile_image/5871202/normal/noobbrad_x150.jpg?1187756051
                            [url] => http://stillframe.com
                            [protected] => false
                        )

                )

            [3] => SimpleXMLElement Object
                (
                    [created_at] => Wed Sep 05 01:44:00 +0000 2007
                    [id] => 247693942
                    [text] => If the Hood blimp ever crashed (upside down), it would say pooH. Just a random epiphony.
                    [source] => txt
                    [user] => SimpleXMLElement Object
                        (
                            [id] => 5871202
                            [name] => Brad
                            [screen_name] => stillframe
                            [location] => Boston, USA
                            [description] => drunk and in jail for arson
                            [profile_image_url] => http://assets1.twitter.com/system/user/profile_image/5871202/normal/noobbrad_x150.jpg?1187756051
                            [url] => http://stillframe.com
                            [protected] => false
                        )

                )

            [4] => SimpleXMLElement Object
                (
                    [created_at] => Wed Sep 05 00:25:31 +0000 2007
                    [id] => 247569882
                    [text] => Working way too late. Must. leave. now. In happier news, Simmy and I put the wraps on the Noob Tee Store. More tomorrow.
                    [source] => twitterrific
                    [user] => SimpleXMLElement Object
                        (
                            [id] => 5871202
                            [name] => Brad
                            [screen_name] => stillframe
                            [location] => Boston, USA
                            [description] => drunk and in jail for arson
                            [profile_image_url] => http://assets1.twitter.com/system/user/profile_image/5871202/normal/noobbrad_x150.jpg?1187756051
                            [url] => http://stillframe.com
                            [protected] => false
                        )

                )

        )

)
is_array($sxe->status): false
SimpleXMLElement Object
(
    [created_at] => Wed Sep 05 18:06:54 +0000 2007
    [id] => 249403592
    [text] => Everyone that gets the new iPod Touch automatically receives a iPhone Wannabe t-shirt and decal.
    [source] => twitterrific
    [user] => SimpleXMLElement Object
        (
            [id] => 5871202
            [name] => Brad
            [screen_name] => stillframe
            [location] => Boston, USA
            [description] => drunk and in jail for arson
            [profile_image_url] => http://assets1.twitter.com/system/user/profile_image/5871202/normal/noobbrad_x150.jpg?1187756051
            [url] => http://stillframe.com
            [protected] => false
        )

)
0
SimpleXMLElement Object
(
    [created_at] => Wed Sep 05 18:06:54 +0000 2007
    [id] => 249403592
    [text] => Everyone that gets the new iPod Touch automatically receives a iPhone Wannabe t-shirt and decal.
    [source] => twitterrific
    [user] => SimpleXMLElement Object
        (
            [id] => 5871202
            [name] => Brad
            [screen_name] => stillframe
            [location] => Boston, USA
            [description] => drunk and in jail for arson
            [profile_image_url] => http://assets1.twitter.com/system/user/profile_image/5871202/normal/noobbrad_x150.jpg?1187756051
            [url] => http://stillframe.com
            [protected] => false
        )

)
1
SimpleXMLElement Object
(
    [created_at] => Wed Sep 05 18:02:46 +0000 2007
    [id] => 249393302
    [text] => iPodTouch? No. iPodBadTouch. Don't touch your iPod that way.
    [source] => twitterrific
    [user] => SimpleXMLElement Object
        (
            [id] => 5871202
            [name] => Brad
            [screen_name] => stillframe
            [location] => Boston, USA
            [description] => drunk and in jail for arson
            [profile_image_url] => http://assets1.twitter.com/system/user/profile_image/5871202/normal/noobbrad_x150.jpg?1187756051
            [url] => http://stillframe.com
            [protected] => false
        )

)
2
SimpleXMLElement Object
(
    [created_at] => Wed Sep 05 17:10:46 +0000 2007
    [id] => 249255522
    [text] => Dear coffee, I forgot to say hi this morning. Apple event is kicking off. Expect more neglect.
    [source] => twitterrific
    [user] => SimpleXMLElement Object
        (
            [id] => 5871202
            [name] => Brad
            [screen_name] => stillframe
            [location] => Boston, USA
            [description] => drunk and in jail for arson
            [profile_image_url] => http://assets1.twitter.com/system/user/profile_image/5871202/normal/noobbrad_x150.jpg?1187756051
            [url] => http://stillframe.com
            [protected] => false
        )

)
3
SimpleXMLElement Object
(
    [created_at] => Wed Sep 05 01:44:00 +0000 2007
    [id] => 247693942
    [text] => If the Hood blimp ever crashed (upside down), it would say pooH. Just a random epiphony.
    [source] => txt
    [user] => SimpleXMLElement Object
        (
            [id] => 5871202
            [name] => Brad
            [screen_name] => stillframe
            [location] => Boston, USA
            [description] => drunk and in jail for arson
            [profile_image_url] => http://assets1.twitter.com/system/user/profile_image/5871202/normal/noobbrad_x150.jpg?1187756051
            [url] => http://stillframe.com
            [protected] => false
        )

)
4
SimpleXMLElement Object
(
    [created_at] => Wed Sep 05 00:25:31 +0000 2007
    [id] => 247569882
    [text] => Working way too late. Must. leave. now. In happier news, Simmy and I put the wraps on the Noob Tee Store. More tomorrow.
    [source] => twitterrific
    [user] => SimpleXMLElement Object
        (
            [id] => 5871202
            [name] => Brad
            [screen_name] => stillframe
            [location] => Boston, USA
            [description] => drunk and in jail for arson
            [profile_image_url] => http://assets1.twitter.com/system/user/profile_image/5871202/normal/noobbrad_x150.jpg?1187756051
            [url] => http://stillframe.com
            [protected] => false
        )

)

------------------------------------------------------------------------------------------

is_array($status): true
Array
(
    [0] => fubble Object
        (
            [var1] => whatever
            [var2] => whatever2
            [var3] => whatever3
            [var4] => whatever4
            [var5] => whatever5
        )

    [1] => fubble Object
        (
            [var1] => whatever
            [var2] => whatever2
            [var3] => whatever3
            [var4] => whatever4
            [var5] => whatever5
        )

    [2] => fubble Object
        (
            [var1] => whatever
            [var2] => whatever2
            [var3] => whatever3
            [var4] => whatever4
            [var5] => whatever5
        )

    [3] => fubble Object
        (
            [var1] => whatever
            [var2] => whatever2
            [var3] => whatever3
            [var4] => whatever4
            [var5] => whatever5
        )

    [4] => fubble Object
        (
            [var1] => whatever
            [var2] => whatever2
            [var3] => whatever3
            [var4] => whatever4
            [var5] => whatever5
        )

)
0
fubble Object
(
    [var1] => whatever
    [var2] => whatever2
    [var3] => whatever3
    [var4] => whatever4
    [var5] => whatever5
)
1
fubble Object
(
    [var1] => whatever
    [var2] => whatever2
    [var3] => whatever3
    [var4] => whatever4
    [var5] => whatever5
)
2
fubble Object
(
    [var1] => whatever
    [var2] => whatever2
    [var3] => whatever3
    [var4] => whatever4
    [var5] => whatever5
)
3
fubble Object
(
    [var1] => whatever
    [var2] => whatever2
    [var3] => whatever3
    [var4] => whatever4
    [var5] => whatever5
)
4
fubble Object
(
    [var1] => whatever
    [var2] => whatever2
    [var3] => whatever3
    [var4] => whatever4
    [var5] => whatever5
)


Actual result:
--------------
SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [type] => array
        )

    [status] => Array
        (
            [0] => SimpleXMLElement Object
                (
                    [created_at] => Wed Sep 05 18:06:54 +0000 2007
                    [id] => 249403592
                    [text] => Everyone that gets the new iPod Touch automatically receives a iPhone Wannabe t-shirt and decal.
                    [source] => twitterrific
                    [user] => SimpleXMLElement Object
                        (
                            [id] => 5871202
                            [name] => Brad
                            [screen_name] => stillframe
                            [location] => Boston, USA
                            [description] => drunk and in jail for arson
                            [profile_image_url] => http://assets1.twitter.com/system/user/profile_image/5871202/normal/noobbrad_x150.jpg?1187756051
                            [url] => http://stillframe.com
                            [protected] => false
                        )

                )

            [1] => SimpleXMLElement Object
                (
                    [created_at] => Wed Sep 05 18:02:46 +0000 2007
                    [id] => 249393302
                    [text] => iPodTouch? No. iPodBadTouch. Don't touch your iPod that way.
                    [source] => twitterrific
                    [user] => SimpleXMLElement Object
                        (
                            [id] => 5871202
                            [name] => Brad
                            [screen_name] => stillframe
                            [location] => Boston, USA
                            [description] => drunk and in jail for arson
                            [profile_image_url] => http://assets1.twitter.com/system/user/profile_image/5871202/normal/noobbrad_x150.jpg?1187756051
                            [url] => http://stillframe.com
                            [protected] => false
                        )

                )

            [2] => SimpleXMLElement Object
                (
                    [created_at] => Wed Sep 05 17:10:46 +0000 2007
                    [id] => 249255522
                    [text] => Dear coffee, I forgot to say hi this morning. Apple event is kicking off. Expect more neglect.
                    [source] => twitterrific
                    [user] => SimpleXMLElement Object
                        (
                            [id] => 5871202
                            [name] => Brad
                            [screen_name] => stillframe
                            [location] => Boston, USA
                            [description] => drunk and in jail for arson
                            [profile_image_url] => http://assets1.twitter.com/system/user/profile_image/5871202/normal/noobbrad_x150.jpg?1187756051
                            [url] => http://stillframe.com
                            [protected] => false
                        )

                )

            [3] => SimpleXMLElement Object
                (
                    [created_at] => Wed Sep 05 01:44:00 +0000 2007
                    [id] => 247693942
                    [text] => If the Hood blimp ever crashed (upside down), it would say pooH. Just a random epiphony.
                    [source] => txt
                    [user] => SimpleXMLElement Object
                        (
                            [id] => 5871202
                            [name] => Brad
                            [screen_name] => stillframe
                            [location] => Boston, USA
                            [description] => drunk and in jail for arson
                            [profile_image_url] => http://assets1.twitter.com/system/user/profile_image/5871202/normal/noobbrad_x150.jpg?1187756051
                            [url] => http://stillframe.com
                            [protected] => false
                        )

                )

            [4] => SimpleXMLElement Object
                (
                    [created_at] => Wed Sep 05 00:25:31 +0000 2007
                    [id] => 247569882
                    [text] => Working way too late. Must. leave. now. In happier news, Simmy and I put the wraps on the Noob Tee Store. More tomorrow.
                    [source] => twitterrific
                    [user] => SimpleXMLElement Object
                        (
                            [id] => 5871202
                            [name] => Brad
                            [screen_name] => stillframe
                            [location] => Boston, USA
                            [description] => drunk and in jail for arson
                            [profile_image_url] => http://assets1.twitter.com/system/user/profile_image/5871202/normal/noobbrad_x150.jpg?1187756051
                            [url] => http://stillframe.com
                            [protected] => false
                        )

                )

        )

)
is_array($sxe->status): false
SimpleXMLElement Object
(
    [created_at] => Wed Sep 05 18:06:54 +0000 2007
    [id] => 249403592
    [text] => Everyone that gets the new iPod Touch automatically receives a iPhone Wannabe t-shirt and decal.
    [source] => twitterrific
    [user] => SimpleXMLElement Object
        (
            [id] => 5871202
            [name] => Brad
            [screen_name] => stillframe
            [location] => Boston, USA
            [description] => drunk and in jail for arson
            [profile_image_url] => http://assets1.twitter.com/system/user/profile_image/5871202/normal/noobbrad_x150.jpg?1187756051
            [url] => http://stillframe.com
            [protected] => false
        )

)
status
SimpleXMLElement Object
(
    [created_at] => Wed Sep 05 18:06:54 +0000 2007
    [id] => 249403592
    [text] => Everyone that gets the new iPod Touch automatically receives a iPhone Wannabe t-shirt and decal.
    [source] => twitterrific
    [user] => SimpleXMLElement Object
        (
            [id] => 5871202
            [name] => Brad
            [screen_name] => stillframe
            [location] => Boston, USA
            [description] => drunk and in jail for arson
            [profile_image_url] => http://assets1.twitter.com/system/user/profile_image/5871202/normal/noobbrad_x150.jpg?1187756051
            [url] => http://stillframe.com
            [protected] => false
        )

)
status
SimpleXMLElement Object
(
    [created_at] => Wed Sep 05 18:02:46 +0000 2007
    [id] => 249393302
    [text] => iPodTouch? No. iPodBadTouch. Don't touch your iPod that way.
    [source] => twitterrific
    [user] => SimpleXMLElement Object
        (
            [id] => 5871202
            [name] => Brad
            [screen_name] => stillframe
            [location] => Boston, USA
            [description] => drunk and in jail for arson
            [profile_image_url] => http://assets1.twitter.com/system/user/profile_image/5871202/normal/noobbrad_x150.jpg?1187756051
            [url] => http://stillframe.com
            [protected] => false
        )

)
status
SimpleXMLElement Object
(
    [created_at] => Wed Sep 05 17:10:46 +0000 2007
    [id] => 249255522
    [text] => Dear coffee, I forgot to say hi this morning. Apple event is kicking off. Expect more neglect.
    [source] => twitterrific
    [user] => SimpleXMLElement Object
        (
            [id] => 5871202
            [name] => Brad
            [screen_name] => stillframe
            [location] => Boston, USA
            [description] => drunk and in jail for arson
            [profile_image_url] => http://assets1.twitter.com/system/user/profile_image/5871202/normal/noobbrad_x150.jpg?1187756051
            [url] => http://stillframe.com
            [protected] => false
        )

)
status
SimpleXMLElement Object
(
    [created_at] => Wed Sep 05 01:44:00 +0000 2007
    [id] => 247693942
    [text] => If the Hood blimp ever crashed (upside down), it would say pooH. Just a random epiphony.
    [source] => txt
    [user] => SimpleXMLElement Object
        (
            [id] => 5871202
            [name] => Brad
            [screen_name] => stillframe
            [location] => Boston, USA
            [description] => drunk and in jail for arson
            [profile_image_url] => http://assets1.twitter.com/system/user/profile_image/5871202/normal/noobbrad_x150.jpg?1187756051
            [url] => http://stillframe.com
            [protected] => false
        )

)
status
SimpleXMLElement Object
(
    [created_at] => Wed Sep 05 00:25:31 +0000 2007
    [id] => 247569882
    [text] => Working way too late. Must. leave. now. In happier news, Simmy and I put the wraps on the Noob Tee Store. More tomorrow.
    [source] => twitterrific
    [user] => SimpleXMLElement Object
        (
            [id] => 5871202
            [name] => Brad
            [screen_name] => stillframe
            [location] => Boston, USA
            [description] => drunk and in jail for arson
            [profile_image_url] => http://assets1.twitter.com/system/user/profile_image/5871202/normal/noobbrad_x150.jpg?1187756051
            [url] => http://stillframe.com
            [protected] => false
        )

)

------------------------------------------------------------------------------------------

is_array($status): true
Array
(
    [0] => fubble Object
        (
            [var1] => whatever
            [var2] => whatever2
            [var3] => whatever3
            [var4] => whatever4
            [var5] => whatever5
        )

    [1] => fubble Object
        (
            [var1] => whatever
            [var2] => whatever2
            [var3] => whatever3
            [var4] => whatever4
            [var5] => whatever5
        )

    [2] => fubble Object
        (
            [var1] => whatever
            [var2] => whatever2
            [var3] => whatever3
            [var4] => whatever4
            [var5] => whatever5
        )

    [3] => fubble Object
        (
            [var1] => whatever
            [var2] => whatever2
            [var3] => whatever3
            [var4] => whatever4
            [var5] => whatever5
        )

    [4] => fubble Object
        (
            [var1] => whatever
            [var2] => whatever2
            [var3] => whatever3
            [var4] => whatever4
            [var5] => whatever5
        )

)
0
fubble Object
(
    [var1] => whatever
    [var2] => whatever2
    [var3] => whatever3
    [var4] => whatever4
    [var5] => whatever5
)
1
fubble Object
(
    [var1] => whatever
    [var2] => whatever2
    [var3] => whatever3
    [var4] => whatever4
    [var5] => whatever5
)
2
fubble Object
(
    [var1] => whatever
    [var2] => whatever2
    [var3] => whatever3
    [var4] => whatever4
    [var5] => whatever5
)
3
fubble Object
(
    [var1] => whatever
    [var2] => whatever2
    [var3] => whatever3
    [var4] => whatever4
    [var5] => whatever5
)
4
fubble Object
(
    [var1] => whatever
    [var2] => whatever2
    [var3] => whatever3
    [var4] => whatever4
    [var5] => whatever5
)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-06 10:43 UTC] jani@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2007-09-06 22:38 UTC] jani@php.net
Please, try come up with shorter script that clearly (!) shows the problem you have. (without the extra empty lines please)
 [2007-09-10 01:06 UTC] hubert dot roksor at gmail dot com
This is not a bug. The reporter expects is_array() to return true when passed a SimpleXML_Element object.

@rockerboo: even though you can access a SimpleXML_Element as an array, it doesn't mean that it is considered as an array, therefore is_array() is expected to return false.
 [2007-09-14 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2008-09-22 12:28 UTC] labibhat at yahoo dot com
hay
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 11:01:30 2024 UTC