php实现foreach遍历结构classTestimplementsIterator{private$item=array('id'=>1,'name'=>'php');/***将索引指定到首个元素*{@inheritDoc}*@seeIterator::rewind()*/publicfunctionrewind(){reset($this->item);}/***返回当前元素*{@inheritDoc}*@seeIterator::current()*/publicfunctioncurrent(){returncurrent($this->item);}/***返回当前元素键值*{@i