xref: /PHP-5.5/ext/simplexml/tests/029.phpt (revision 610c7fbe)
1--TEST--
2SimpleXML: foreach and count
3--SKIPIF--
4<?php if (!extension_loaded("simplexml")) print "skip"; ?>
5--FILE--
6<?php
7$xml =<<<EOF
8<people>
9  <person name="Joe"/>
10  <person name="John">
11    <children>
12      <person name="Joe"/>
13    </children>
14  </person>
15  <person name="Jane"/>
16</people>
17EOF;
18
19$people = simplexml_load_string($xml);
20
21foreach($people as $person)
22{
23	var_dump((string)$person['name']);
24	var_dump(count($people));
25	var_dump(count($person));
26}
27
28?>
29===DONE===
30--EXPECTF--
31string(3) "Joe"
32int(3)
33int(0)
34string(4) "John"
35int(3)
36int(1)
37string(4) "Jane"
38int(3)
39int(0)
40===DONE===
41