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--EXPECT-- 30string(3) "Joe" 31int(3) 32int(0) 33string(4) "John" 34int(3) 35int(1) 36string(4) "Jane" 37int(3) 38int(0) 39