Created
February 22, 2014 08:22
-
-
Save tournasdim/9150448 to your computer and use it in GitHub Desktop.
SPL's LimitIterator , a simple example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$numbers = array(22, 60, 876, 95, 77); | |
// Initializing the Iterator | |
$iterator = new ArrayIterator($numbers); | |
// Pass the converted array to the LimitIterator | |
$limiter = new LimitIterator($iterator, 0 , 4); | |
// Loop through the LimitIterator object | |
foreach ($limiter as $number) { | |
echo $number . '<br />'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment