p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: Iterating non-sequential arrays - index or populated order? - pp. 172-177


Message #1 by sandmman@d... on Sat, 23 Feb 2002 12:37:43
I am confused by the book - the statements do not match the examples for 

iterating through non-sequential arrays, and using current(), key(), 

list() and each() functions.



E.g. on page 177, first sentence, top of the page, says that with a simple 

while loop using the each() function, php (shown at the bottom of page 

176) "will produce a list...and display them in the order you created them 

[in other words, in the order in which they were populated]" The very next 

paragraph on that page says the opposite: "...PHP will navigate [the 

elements of a non-sequential array] in index order, no matter which order 

you populate the elements...." Which is it?



Thanks, much.



sandmman
Message #2 by "Hermawan Haryanto" <hermawan@h...> on Sat, 23 Feb 2002 21:13:21 +0700
Hiks, I don't have any books, could some one be so kind to send me that book

?



Thanks



Hermawan Haryanto

hermawan@h...



----- Original Message -----

From: <sandmman@d...>

To: "beginning php" <beginning_php@p...>

Sent: Saturday, February 23, 2002 12:37 PM

Subject: [beginning_php] Iterating non-sequential arrays - index or

populated order? - pp. 172-177





> I am confused by the book - the statements do not match the examples for

> iterating through non-sequential arrays, and using current(), key(),

> list() and each() functions.

>

> E.g. on page 177, first sentence, top of the page, says that with a simple

> while loop using the each() function, php (shown at the bottom of page

> 176) "will produce a list...and display them in the order you created them

> [in other words, in the order in which they were populated]" The very next

> paragraph on that page says the opposite: "...PHP will navigate [the

> elements of a non-sequential array] in index order, no matter which order

> you populate the elements...." Which is it?

>

> Thanks, much.

>

> sandmman




$subst('Email.Unsub').

>



Message #3 by sandmman@d... on Mon, 25 Feb 2002 16:16:00
We can forget the book (Choi, and others, "Beginning PHP4" from Wrox).



All I really want to know is this:



Given the following non-sequential) array, named $nonseqarray:



$Array[56993]="element value added first";

$Array[1]="element value added second";

$Array[499]="element value added third";



Will the function current($nonseqarray) return: 

A.)the first-listed element in the array, with the value "element added 

first" 



OR



B.) the first-indexed element in the array, with the value "element added 

second"?



Thanks, some more.

sandmman 



> Hiks, I don't have any books, could some one be so kind to send me that 

book

> ?

> 

> Thanks

> 

> Hermawan Haryanto

> hermawan@h...

> 

> ----- Original Message -----

> From: <sandmman@d...>

> To: "beginning php" <beginning_php@p...>

> Sent: Saturday, February 23, 2002 12:37 PM

> Subject: [beginning_php] Iterating non-sequential arrays - index or

> populated order? - pp. 172-177

> 

> 

> > I am confused by the book - the statements do not match the examples 

for

> > iterating through non-sequential arrays, and using current(), key(),

> > list() and each() functions.

> >

> > E.g. on page 177, first sentence, top of the page, says that with a 

simple

> > while loop using the each() function, php (shown at the bottom of page

> > 176) "will produce a list...and display them in the order you created 

them

> > [in other words, in the order in which they were populated]" The very 

next

> > paragraph on that page says the opposite: "...PHP will navigate [the

> > elements of a non-sequential array] in index order, no matter which 

order

> > you populate the elements...." Which is it?

> >

> > Thanks, much.

> >

> > sandmman




> $subst('Email.Unsub').

> >

> 


  Return to Index