1--TEST-- 2SPL: ArrayIterator::count 3--FILE-- 4<?php 5 6echo "===Array===\n"; 7 8$a = array('zero' => 0, 'one' => 1, 'two' => 2); 9$it = new ArrayIterator($a); 10 11var_dump($it->count()); 12foreach($it as $key => $val) 13{ 14 echo "$key=>$val\n"; 15 var_dump($it->count()); 16} 17var_dump($it->count()); 18 19echo "===Object===\n"; 20 21class test 22{ 23 public $zero = 0; 24 protected $pro; 25 public $one = 1; 26 private $pri; 27 public $two = 2; 28} 29 30$o = new test; 31$it = new ArrayIterator($o); 32 33var_dump($it->count()); 34foreach($it as $key => $val) 35{ 36 echo "$key=>$val\n"; 37 var_dump($it->count()); 38} 39var_dump($it->count()); 40 41?> 42--EXPECT-- 43===Array=== 44int(3) 45zero=>0 46int(3) 47one=>1 48int(3) 49two=>2 50int(3) 51int(3) 52===Object=== 53int(3) 54zero=>0 55int(3) 56one=>1 57int(3) 58two=>2 59int(3) 60int(3) 61