質問

I am Studying about PHP SPL - (Standard PHP Library), And i am having some problems understanding the interface Iterator.

I am studying from this example:Iterator Interface.

And i am really dont understand how does Iterator Interface allow us to run with a "foreach" loop trough the class elements, I will be very thankful if some one can please pass me trough this code, Thank you all and have a nice day.

役に立ちましたか?

解決

The interface defines a couple of functions that are needed to allow you to "run with a foreach loop". The whole idea is that there is no code, just an interface.

The functions are listed in the manual, and there is also an example with code on how to use them:

http://php.net/manual/en/class.iterator.php

Can't be clearer than that really.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top