ID: 27288
Updated by: [EMAIL PROTECTED]
Reported By: marcels at korton dot nl
-Status: Feedback
+Status: Bogus
Bug Type: XML related
Operating System: Windows 2000 SP3
PHP Version: 5.0.0b4 (beta4)
New Comment:
Arrays are no longer returned. The objects implement iterators so use
foreach, ie:
foreach ($xml_mem->book->bookbody->part as $part) {
foreach($part->chapter as $chapter) {
echo $chapter->chapheader->title.'<br>';
}
}
Previous Comments:
------------------------------------------------------------------------
[2004-02-17 06:11:16] [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 possible, make the script source available online and provide
an URL to it here. Try avoid embedding huge scripts into the report.
------------------------------------------------------------------------
[2004-02-17 03:50:33] marcels at korton dot nl
Description:
------------
When I use the count function to get the number of elements in an array
it returns 1. It does this only when I use simpleXML. In version
5.0.0b3 it worked fine.
My example use a book in the xml format. Here is a small part of it
<bookbody>
<part>
<chapter>
<chapheader>
<chapnum>I</chapnum>
<title>The Period</title>
</chapheader>
</chapter>
<chapter>
<chapheader>
<chapnum>II</chapnum>
<title>The Mail</title>
</chapheader>
This continues for al the chapters within the book.
both part and chapter are array's.
We are using the windows precompiled binaries with Sambar server V6.0
build 11 november 2003
Reproduce code:
---------------
$xml_mem = simplexml_load_file('2city11.xml');
for ($i = 0; $i < count($xml_mem->book->bookbody->part); $i++) {
for ($j = 0; $j < count($xml_mem->book->bookbody->part[$i]->chapter);
$j++) {
echo
$xml_mem->book->bookbody->part[$i]->chapter[$j]->chapheader->title,'<br>';
}
}
Expected result:
----------------
The Period
The Mail
The Night Shadows
The Preparation
The Wine-shop
The Shoemaker
Five Years Later
A Sight
A Disappointment
...
Actual result:
--------------
The Period
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27288&edit=1