ID: 42571 User updated by: rockerboo at gmail dot com Reported By: rockerboo at gmail dot com -Status: Feedback +Status: Open Bug Type: SimpleXML related Operating System: CentOS 5 PHP Version: 5.2.4 New Comment:
Reproducing code: http://pastebin.com/f4a23f14d When creating an SimpleXmlElement and passing the following xml, there are unexpected results. <nodes><node><entry>Entry1</entry></node><node><entry>Entry2</entry></node></nodes> Which creates this SimpleXmlElement object SimpleXMLElement Object ( [node] => Array ( [0] => SimpleXMLElement Object ( [entry] => Entry1 ) [1] => SimpleXMLElement Object ( [entry] => Entry2 ) ) ) This is expected. When I try to print_r on the SimpleXMLElement->node, which is an array with 2 elements, it shows the following. print_r(SimpleXMLElement->node); SimpleXMLElement Object ( [entry] => Entry1 ) Which shows only 1 element, and not a listing of the 2 elements in the array. Furthermore, if I check to see if SimpleXMLElement->node is an array, it returns false. echo is_array(SimpleXMLElement->node); And further, if I try to loop through the elements of SimpleXMLElement->node, it works, but the key is always 'node' instead of the numeric 0,1 key. The reproduce code shows both expected and the unexpected results. Previous Comments: ------------------------------------------------------------------------ [2007-09-06 10:43:35] [EMAIL PROTECTED] 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-05 20:01:16] 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 ( [EMAIL PROTECTED] => 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 ( [EMAIL PROTECTED] => 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 ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42571&edit=1
