25.09.2014 Views

ZEND PHP 5 Certification STUDY GUIDE

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

180 ” Elements of Object-oriented Design<br />

interface SeekableIterator {<br />

function current();<br />

function next();<br />

function rewind();<br />

function key();<br />

function valid();<br />

function seek($index);<br />

}<br />

Recursive Iteration<br />

Recursive Iteration allows looping over multi-dimensional tree-like data structures.<br />

SimpleXML, for example, uses recursive iteration to allow looping through complex<br />

XML document trees.<br />

To understand how this works, consider the following complex array:<br />

$company = array(<br />

array("Acme Anvil Co."),<br />

array(<br />

array(<br />

"Human Resources",<br />

array(<br />

"Tom",<br />

"Dick",<br />

"Harry"<br />

)<br />

),<br />

array(<br />

"Accounting",<br />

array(<br />

"Zoe",<br />

"Duncan",<br />

"Jack",<br />

"Jane"<br />

)<br />

)<br />

)<br />

);<br />

Licensed to 482634 - Amber Barrow (itsadmin@deakin.edu.au)<br />

Our goal is to print out something like this:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!