- var_dump: documentation ( source)
- range: documentation ( source)
<?php
class Derp implements Iterator
{
protected $index;
protected $array;
public function __construct(array $input) {
$this->array = $input;
}
public function current()
{
return $this->array[$this->index];
}
public function next()
{
$this->index += 1;
}
public function key()
{
return $this->index;
}
public function valid()
{
return isset($this->array[$this->index]);
}
public function rewind()
{
$this->index = 0;
}
}
$d = new Derp(range(1,100));
var_dump(is_array($d));
foreach($d as $key => $value) {
echo "$key => $value\n";
}