Prototyping for a class returning items one by one
<?php class printer { function printer() { $in = new data(); while($line = $in->getNext()) { echo $line; echo "\n"; } return; } } class data { function __construct() { $this->i = 0; } function getNext() { $dat = array(1,2,3,4,5,6,7,8); if($this->i < count($dat)) { return $dat[$this->i++]; } else { return FALSE; } } } $out = new printer(); $out->printer(); exit; ?>