functional programming with spl iterators debug...

58
Functional Programming with SPL Iterators Debug Session Marcus Börger international PHP2004 conference

Upload: others

Post on 07-Jul-2020

17 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Functional Programming with SPL Iterators

Debug Session

Marcus Börger

international PHP2004 conference

Page 2: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 2

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

Page 3: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 3

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

Page 4: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 4

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

Page 5: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 5

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

Page 6: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 6

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

Page 7: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 7

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

Page 8: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 8

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

Page 9: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 9

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

Page 10: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 10

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

Page 11: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 11

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

Page 12: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 12

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

Page 13: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 13

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

Page 14: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 14

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

0 => 1

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

Page 15: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 15

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 1

Page 16: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 16

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 1

Page 17: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 17

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 1

Page 18: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 18

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 1

Page 19: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 19

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 1

Page 20: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 20

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 1

Page 21: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 21

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 1

Page 22: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 22

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 2

Page 23: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 23

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 2

Page 24: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 24

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 2

Page 25: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 25

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 2

Page 26: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 26

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 2

Page 27: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 27

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 2

Page 28: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 28

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 2

Page 29: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 29

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 2

Page 30: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 30

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 2

Page 31: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 31

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 2

Page 32: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 32

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 2

Page 33: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 33

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 2

Page 34: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 34

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 2

Page 35: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 35

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

0 => 11 => 20 => 31

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

Page 36: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 36

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 20 => 31

Page 37: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 37

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 20 => 31

Page 38: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 38

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 20 => 31

Page 39: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 39

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 20 => 31

Page 40: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 40

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 20 => 31

Page 41: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 41

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 20 => 31

Page 42: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 42

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 20 => 31

Page 43: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 43

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

0 => 11 => 20 => 311 => 32

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

Page 44: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 44

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 20 => 311 => 32

Page 45: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 45

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 20 => 311 => 32

Page 46: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 46

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 20 => 311 => 32

Page 47: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 47

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 20 => 311 => 32

Page 48: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 48

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 20 => 311 => 32

Page 49: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 49

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 20 => 311 => 32

Page 50: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 50

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 20 => 311 => 32

Page 51: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 51

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 20 => 311 => 32

Page 52: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 52

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 20 => 311 => 32

Page 53: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 53

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 20 => 311 => 323 => 4

Page 54: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 54

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 20 => 311 => 323 => 4

Page 55: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 55

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 20 => 311 => 323 => 4

Page 56: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 56

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 20 => 311 => 323 => 4

Page 57: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 57

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 20 => 311 => 323 => 4

Page 58: Functional Programming with SPL Iterators Debug Sessionsomabo.de/talks/talks/200411_php_conference_frankfrurt_iterator_d… · Functional Programming with SPL Iterators Debug Session

Marcus Börger Debug Session 58

Deb

ug S

essi

on

<?php$a = array('1','2',array('31','32'),'4');$o = new RecursiveArrayIterator($a);$i = new RecursiveIteratorIterator($o);foreach($i as $key => $val) {

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

<?phpclass RecursiveArrayIterator implements RecursiveIterator {

protected $ar;function __construct(Array $ar) {

$this->ar = $ar; }function rewind() {

reset($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); }function hasChildren() {

return is_array(current($this->ar)); }function getChildren() {

return new RecursiveArrayIterator(current($this->ar)); }}?>

0 => 11 => 20 => 311 => 323 => 4