introduction to iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... ·...

71
Introduction to Iterators Debug Session Marcus Börger LinuxTag 2004 Karlsruhe

Upload: others

Post on 28-Jun-2020

20 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Introduction to IteratorsDebug Session

Marcus Börger

LinuxTag 2004 Karlsruhe

Page 2: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 2

An example<?php

class ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

Page 3: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 3

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

Page 4: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 4

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

Page 5: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 5

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

Page 6: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 6

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

Page 7: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 7

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

Page 8: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 8

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

Page 9: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 9

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

Page 10: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 10

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

Page 11: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 11

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

Page 12: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 12

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

Page 13: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 13

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

Page 14: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 14

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

Page 15: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 15

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

Page 16: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 16

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

Page 17: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 17

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

Page 18: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 18

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

Page 19: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 19

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

Page 20: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 20

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

Page 21: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 21

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

Page 22: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 22

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

Page 23: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 23

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

Page 24: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 24

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

Page 25: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 25

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 1

Page 26: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 26

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 1

Page 27: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 27

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 1

Page 28: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 28

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 1

Page 29: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 29

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 1

Page 30: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 30

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 1

Page 31: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 31

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 1

Page 32: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 32

An example<?phpclass ArrayIterator extends 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);}

}?>

<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 1

Page 33: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 33

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 1

<?phpclass ArrayIterator extends 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);}

}?>

Page 34: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 34

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 1

<?phpclass ArrayIterator extends 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);}

}?>

Page 35: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 35

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 1

<?phpclass ArrayIterator extends 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);}

}?>

Page 36: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 36

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 1

<?phpclass ArrayIterator extends 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);}

}?>

Page 37: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 37

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 1

<?phpclass ArrayIterator extends 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);}

}?>

Page 38: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 38

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 1

<?phpclass ArrayIterator extends 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);}

}?>

Page 39: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 39

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 1

<?phpclass ArrayIterator extends 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);}

}?>

Page 40: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 40

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 1

<?phpclass ArrayIterator extends 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);}

}?>

Page 41: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 41

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 1

<?phpclass ArrayIterator extends 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);}

}?>

Page 42: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 42

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 1

<?phpclass ArrayIterator extends 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);}

}?>

Page 43: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 43

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 2

<?phpclass ArrayIterator extends 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);}

}?>

Page 44: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 44

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 2

<?phpclass ArrayIterator extends 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);}

}?>

Page 45: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 45

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 2

<?phpclass ArrayIterator extends 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);}

}?>

Page 46: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 46

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 2

<?phpclass ArrayIterator extends 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);}

}?>

Page 47: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 47

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 2

<?phpclass ArrayIterator extends 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);}

}?>

Page 48: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 48

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 2

<?phpclass ArrayIterator extends 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);}

}?>

Page 49: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 49

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 2

<?phpclass ArrayIterator extends 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);}

}?>

Page 50: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 50

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 2

<?phpclass ArrayIterator extends 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);}

}?>

Page 51: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 51

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 2

<?phpclass ArrayIterator extends 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);}

}?>

Page 52: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 52

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 2

<?phpclass ArrayIterator extends 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);}

}?>

Page 53: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 53

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 2

<?phpclass ArrayIterator extends 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);}

}?>

Page 54: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 54

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 2

<?phpclass ArrayIterator extends 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);}

}?>

Page 55: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 55

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 2

<?phpclass ArrayIterator extends 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);}

}?>

Page 56: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 56

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 2

<?phpclass ArrayIterator extends 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);}

}?>

Page 57: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 57

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 2

<?phpclass ArrayIterator extends 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);}

}?>

Page 58: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 58

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 2

<?phpclass ArrayIterator extends 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);}

}?>

Page 59: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 59

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 2

<?phpclass ArrayIterator extends 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);}

}?>

Page 60: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 60

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 2

<?phpclass ArrayIterator extends 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);}

}?>

Page 61: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 61

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 22 => 3

<?phpclass ArrayIterator extends 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);}

}?>

Page 62: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 62

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 22 => 3

<?phpclass ArrayIterator extends 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);}

}?>

Page 63: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 63

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 22 => 3

<?phpclass ArrayIterator extends 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);}

}?>

Page 64: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 64

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 22 => 3

<?phpclass ArrayIterator extends 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);}

}?>

Page 65: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 65

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 22 => 3

<?phpclass ArrayIterator extends 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);}

}?>

Page 66: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 66

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 22 => 3

<?phpclass ArrayIterator extends 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);}

}?>

Page 67: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 67

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 22 => 3

<?phpclass ArrayIterator extends 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);}

}?>

Page 68: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 68

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 22 => 3

<?phpclass ArrayIterator extends 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);}

}?>

Page 69: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 69

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 22 => 3

<?phpclass ArrayIterator extends 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);}

}?>

Page 70: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 70

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 22 => 3

<?phpclass ArrayIterator extends 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);}

}?>

Page 71: Introduction to Iterators - somabo.desomabo.de/talks/talks/200406_linuxtag_introduction... · Marcus Börger Introduction to Iterators 2 An example

Marcus Börger Introduction to Iterators 71

An example<?php$a = array(1, 2, 3);$o = new ArrayIterator($a);foreach($o as $key => $val) {

echo "$key => $va\n";}?>

0 => 11 => 22 => 3

<?phpclass ArrayIterator extends 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);}

}?>