Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Iterator

<?php
class myIterator implements Iterator {
    private $position = 0;
    private $array = array(
        "firstelement",
        "secondelement",
        "lastelement",
    );  

    public function __construct() {
        $this->position = 0;
    }

    public function rewind() {
        var_dump(__METHOD__);
        $this->position = 0;
    }

    public function current() {
        var_dump(__METHOD__);
        return $this->array[$this->position];
    }

    public function key() {
        var_dump(__METHOD__);
        return $this->position;
    }

    public function next() {
        var_dump(__METHOD__);
        ++$this->position;
    }

    public function valid() {
        var_dump(__METHOD__);
        return isset($this->array[$this->position]);
    }
}

$it = new myIterator;

foreach($it as $key => $value) {
    var_dump($key, $value);
    echo "
";
}
?>
Comment

PREVIOUS NEXT
Code Example
Php :: laravel debugbar ServiceProvider to the providers 
Php :: php check empty variable 
Php :: all() in laravel 
Php :: send data to api php 
Php :: php var_dump() 
Php :: auto logout when session expires laravel 
Php :: php leggere file txt riga per riga 
Php :: https://github.com/nuxt/nuxt.js/issues/8315#:~:text=%3Chtml%20lang%3D%22ru%22%20data%2Dn%2Dhead%3D%22%257B%2522lang%2522%3A%257B%2522ssr%2522%3A%2522ru%2522%257D%257D%22%3E 
Php :: php save array to files a 
Php :: php how to check if user has a role on login 
Php :: woocommerce_rest_cannot_view 
Php :: export laravel path fedora 
Php :: myr currency symbol 
Php :: php integer to js integer 
Php :: wordpress html classes 
Php :: radio button in php form 
Php :: Protect Your Site from Malicious Requests 
Php :: laravel how to address to git repo for develop packages 
Php :: extract email from text 
Php :: How to validate Envato Purchase Code in PHP 
Php :: Change Initial Country For Caldera Forms Phone Fields 
Php :: sorting table row data with php 
Php :: Nginx + Laravel - Moving blog from subdomain to /blog 
Php :: add selected to dropdpown item laravel 
Php :: set php variabe with javascript loca storage 
Php :: wp retrieve acf by category name 
Php :: php check if cli mode 
Php :: php random array name 
Php :: laravel 8 api validation 
Php :: __sleep and __wakeup 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =