as i said earlier the purpose of an iterator is to hide the internal
representation of an object.
ive been thinking about it the past couple of days and the odd thing with
php is, well in php,
the array construct is used to store almost everything complex. in java
there are lots of different
On Sun, July 22, 2007 9:02 pm, Kevin Waterson wrote:
This one time, at band camp, Nathan Nobbe [EMAIL PROTECTED]
wrote:
Thanks for the response.
I was hoping to avoid this sort of recursion within userspace and keep
it at a lower level. Should not the recursive iterator recurse so we
dont
This one time, at band camp, Jim Lucas [EMAIL PROTECTED] wrote:
I don't get it, why not do this?
foreach ( $array AS $row ) {
foreach ( $row AS $k = $v ) {
if ( ! is_array($v) ) {
echo {$k} -- {$v}br/\n;
}
}
}
Maybe I am
the purpose of an iterator is to allow client code to access the various
(aggregate) components of an object while concealing its underlying
implementation.
the client code only has to know about the iterators interface. thus 1 or
more objects that all have a potentially different data profile
On Monday 23 July 2007, Kevin Waterson wrote:
This one time, at band camp, Jim Lucas [EMAIL PROTECTED] wrote:
I don't get it, why not do this?
foreach ( $array AS $row ) {
foreach ( $row AS $k = $v ) {
if ( ! is_array($v) ) {
echo {$k} -- {$v}br/\n;
On 7/23/07, Larry Garfield [EMAIL PROTECTED] wrote:
Isn't that what garbage collection is for?
well garbage collection will remove the copy of an array created by foreach,
but what Kevin
is saying is Iterators dont bother creating a copy of the array, which
overall results in memory
savings.
On Mon, 2007-07-23 at 10:39 -0400, Nathan Nobbe wrote:
On 7/23/07, Larry Garfield [EMAIL PROTECTED] wrote:
Isn't that what garbage collection is for?
well garbage collection will remove the copy of an array created by foreach,
but what Kevin
is saying is Iterators dont bother creating a
When I run the code below, I get an output of the array which is good.
But the first member of the array output is 0=Array. Is there a way to
prevent this? eg:
0 -- Array
name -- butch
sex -- m
breed -- boxer
name -- fido
sex -- m
breed -- doberman
name -- girly
sex -- f
breed -- poodle
?php
Kevin,
im not sure why you need the RecursiveIteratorIterator; the
RecursiveArrayIterator is capable of handling the nested arrays by itself.
here is a revision of the code you posted, using PHP_EOL for newlines since
i developed this via the CLI.
?php
$array = array(
array('name'='butch',
This one time, at band camp, Nathan Nobbe [EMAIL PROTECTED] wrote:
Thanks for the response.
I was hoping to avoid this sort of recursion within userspace and keep
it at a lower level. Should not the recursive iterator recurse so we
dont need to be using user defined functions?
This is what I have so far..
?php
$array = array(
array('name'='butch', 'sex'='m', 'breed'='boxer'),
array('name'='fido', 'sex'='m', 'breed'='doberman'),
array('name'='girly','sex'='f', 'breed'='poodle')
);
$iterator = new RecursiveIteratorIterator(new
there is no base case in the printArrayKeysRecursively method;
therefore it is not handling recursion; its just using the
RecursiveArrayItereators public methods. i think that is totally appropriate.
but i believe i understand what youre getting at; namely the
RecursiveArrayIterator implments
Kevin Waterson wrote:
This is what I have so far..
?php
$array = array(
array('name'='butch', 'sex'='m', 'breed'='boxer'),
array('name'='fido', 'sex'='m', 'breed'='doberman'),
array('name'='girly','sex'='f', 'breed'='poodle')
);
$iterator = new RecursiveIteratorIterator(new
13 matches
Mail list logo