} public function fetch() { $val = each($this->arr); if ($val) { return $val['value']; } else { reset($this->arr); return false; } } } //variant 1 $ob = new Phrase($str); echo "<ul>"; while (($word = $ob->fetch()) !== false) { echo "<li>" . $word . "</li>"; } echo "</ul>"; //step 2 class Phrase2 implements Iterator { public $arr; public function __construct($str) { $this->arr = explode(" ", $str); $this->n = count($this->arr); } public function rewind() { $this->k = 0;