Introduction to Iterators Debug Session Marcus Brger OSCON

  • Slides: 71
Download presentation
Introduction to Iterators Debug Session Marcus Börger OSCON 2004 Marcus Börger Introduction to Iterators

Introduction to Iterators Debug Session Marcus Börger OSCON 2004 Marcus Börger Introduction to Iterators

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > Introduction to Iterators 2

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > Introduction to Iterators 3

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > Introduction to Iterators 4

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > Introduction to Iterators 5

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > Introduction to Iterators 6

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > Introduction to Iterators 7

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > Introduction to Iterators 8

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > Introduction to Iterators 9

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > Introduction to Iterators 10

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > Introduction to Iterators 11

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > Introduction to Iterators 12

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > Introduction to Iterators 13

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > Introduction to Iterators 14

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > Introduction to Iterators 15

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > Introduction to Iterators 16

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > Introduction to Iterators 17

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > Introduction to Iterators 18

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > Introduction to Iterators 19

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > Introduction to Iterators 20

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > Introduction to Iterators 21

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > Introduction to Iterators 22

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > Introduction to Iterators 23

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > Introduction to Iterators 24

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 Introduction to Iterators 25

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 Introduction to Iterators 26

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 Introduction to Iterators 27

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 Introduction to Iterators 28

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 Introduction to Iterators 29

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 Introduction to Iterators 30

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 Introduction to Iterators 31

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 Introduction to Iterators 32

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 Introduction to Iterators 33

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 Introduction to Iterators 34

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 Introduction to Iterators 35

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 Introduction to Iterators 36

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 Introduction to Iterators 37

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 Introduction to Iterators 38

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 Introduction to Iterators 39

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 Introduction to Iterators 40

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 Introduction to Iterators 41

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 Introduction to Iterators 42

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 Introduction to Iterators 43

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 Introduction to Iterators 44

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 Introduction to Iterators 45

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 Introduction to Iterators 46

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 Introduction to Iterators 47

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 Introduction to Iterators 48

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 Introduction to Iterators 49

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 Introduction to Iterators 50

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 Introduction to Iterators 51

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 Introduction to Iterators 52

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 Introduction to Iterators 53

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 Introduction to Iterators 54

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 Introduction to Iterators 55

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 Introduction to Iterators 56

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 Introduction to Iterators 57

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 Introduction to Iterators 58

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 Introduction to Iterators 59

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 Introduction to Iterators 60

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 2 => 3 Introduction to Iterators 61

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 2 => 3 Introduction to Iterators 62

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 2 => 3 Introduction to Iterators 63

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 2 => 3 Introduction to Iterators 64

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 2 => 3 Introduction to Iterators 65

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 2 => 3 Introduction to Iterators 66

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 2 => 3 Introduction to Iterators 67

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 2 => 3 Introduction to Iterators 68

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 2 => 3 Introduction to Iterators 69

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 2 => 3 Introduction to Iterators 70

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) {

An example <? php class Array. Iterator { protected $ar; function __construct(Array $ar) { $this->ar = $ar; } function rewind() { rewind($this->ar); } function valid() { return !is_null(key($this->ar)); } function key() { return key($this->ar); } function current() { return current($this->ar); } function next() { next($this->ar); } } ? > Marcus Börger <? php $a = array(1, 2, 3); $o = new Array. Iterator($a); foreach($o as $key => $val) { echo "$key => $van"; } ? > 0 => 1 1 => 2 2 => 3 Introduction to Iterators 71