- var_dump: documentation ( source)
- get_object_vars: documentation ( source)
<?php
class values implements IteratorAggregate
{
protected $iterator;
public function __construct($objOrArr) {
if(is_array($objOrArr)) {
$this->iterator = new ArrayObject($objOrArr);
} else if(is_object($objOrArr)) {
$this->iterator = new ArrayObject(get_object_vars($objOrArr));
} else {
throw new Exception('$objOrArray is neither an array or an object');
}
}
public function getIterator() {
return $this->iterator;
}
}
$values = new values(new DateTime());
for ($i = 0; $i < 100; $i++){
foreach($values as $k => $v) {
var_dump($k, $v);
}
}