- var_dump: documentation ( source)
- reset: documentation ( source)
- key: documentation ( source)
- next: documentation ( source)
<?php
class Maps implements Iterator
{
protected $key, $data;
public function __construct()
{
$key = new stdClass;
$value = new stdClass;
$key->long = 1.1;
$key->lat = 42.0;
$value = "New York, NY";
$this->data[] = array($key, $value);
$key->long = 2.2;
$key->lat = 24.0;
$value = "Rochester, NY";
$this->data[] = array($key, $value);
}
public function key()
{
return $this->data[0];
}
public function current()
{
return $this->data[1];
}
public function next()
{
next($this->data);
}
public function valid()
{
return key($this->data) !== null;
}
public function rewind()
{
reset($this->data);
}
}
$maps = new Maps;
foreach($maps as $keyMap => $locationMap) {
var_dump($keyMap);
}