Re: SPL Iterator and Associative Array

From: Date: Sat, 03 Jun 2006 02:38:47 +0000
Subject: Re: SPL Iterator and Associative Array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-237310@lists.php.net to get a copy of this message
Jason Karns wrote: > I'm going to try my best to explain what I'm trying to do. > > I have my own class that has an array member. This class itself implements > Iterator. One of the fields in the array is itself an array that I would > like to iterate over. Here's some code: > > class Folio implements Iterator { > $projects = array( > array( > 'title'=>"", > 'clip'=>"", > 'small'=>array('1','2','3')), > array( > 'title'=>"", > 'clip'=>"", > 'small'=>array('0','1','2')) > ); > function title($x){ > return current($this->projects[$]['small']); ^^ > } > > function smalls($x){ > return $this->projects[$x]['small']; > } > } <snip> Hi Jason, The code you pasted is littered with fatal errors and bugs (I marked one example with "^^" above). Please paste a real batch of code that you've tested and reproduces the error and that will be much more helpful. The PHP version would be helpful to know as well. Greg

« previous php.general (#237310) next »