//Countable
class CountMe implements Countable
{
protected $myCount = 3;
public function count()
{
return $this->myCount;
}
}
$obj = new CountMe();
echo count($obj);
//OuterIterator
$array = ['value1','value2','value3','value4'];
$outerObj = new OuterImp(new ArrayIterator($array));
foreach ($outerObj as $key => $value) {
echo "++" . $key . "-" . $value . "\n";
}
class OuterImp extends IteratorIterator
{
public function current()
{
return parent::current() . "_tail";
}
public function key()
{
return "prev" . parent::key();
}
}