Re: [PHP] Looping through array

2006-11-16 Thread Paul Novitski
At 11/16/2006 12:19 PM, Ashley M. Kirchner wrote: Say I have an array containing ten items, and I want to display them in a table as follows: 5 4 3 2 1 10 9 8 7 6 What's the best way to loop through that array to do that? My thinking gets me to create a loop for 5 through 1, re

Re: [PHP] Looping through array

2006-11-16 Thread tedd
At 1:19 PM -0700 11/16/06, Ashley M. Kirchner wrote: Say I have an array containing ten items, and I want to display them in a table as follows: 5 4 3 2 1 10 9 8 7 6 What's the best way to loop through that array to do that? My thinking gets me to create a loop for 5 through 1,

Re: [PHP] Looping through array

2006-11-16 Thread Ashley M. Kirchner
Darrell Brogdon wrote: So in other words, you have an array like $arr = array(1,2,3,4,5,6,7,8,9,10) but you want it to render on the page as: 5 4 3 2 1 10 9 8 7 6 right? That would be correct. James Tu provided a solution that I think will work. I'm always open to other suggestions of

Re: [PHP] Looping through array

2006-11-16 Thread Darrell Brogdon
So in other words, you have an array like $arr = array (1,2,3,4,5,6,7,8,9,10) but you want it to render on the page as: 5 4 3 2 1 10 9 8 7 6 right? -D On Nov 16, 2006, at 1:35 PM, Ashley M. Kirchner wrote: Darrell Brogdon wrote: $arr = array(5, 4, 3, 2, 1, 10, 9, 8, 7, 6,); The

Re: [PHP] Looping through array

2006-11-16 Thread James Tu
$arr = array(...); $first_row = ''; $second_row = ''; for ($i=4; $i>=0; $i--){ $first_row = $first_row . "{$arr[$x]}"; $second_row = $second_row . "{$arr[$x + 5]}"; } print '' . $first_row . '/'; print '' . $second_row . '/'; On Nov 16, 2006, at 3:19 PM, Ashley M. Kirchner wrote

Re: [PHP] Looping through array

2006-11-16 Thread Dave Goodchild
If you know the array elements, you may not need to loop. Why not just echo the particular array elements i.e. for example?

Re: [PHP] Looping through array

2006-11-16 Thread Ashley M. Kirchner
Brad Bonkoski wrote: Something like this perhaps... $arr = array(...); $per_row = 5; $elem = count($arr); for($i=0; $i<$elem; $i++) { if( $i == 0 ) echo ""; else if( $i % $per_row == 0 ) echo ""; echo "$arr[$i]"; } That simply displays things in order, 1 through 5, then

Re: [PHP] Looping through array

2006-11-16 Thread Darrell Brogdon
'; echo ''; for ($x=0,$y=sizeof($arr); $x<$y; ++$x) { echo "{$arr[$x]}"; if ($x == 4) { echo ''; } } echo ''; echo ''; ?> On Nov 16, 2006, at 1:19 PM,

Re: [PHP] Looping through array

2006-11-16 Thread Brad Bonkoski
Ashley M. Kirchner wrote: Say I have an array containing ten items, and I want to display them in a table as follows: 5 4 3 2 1 10 9 8 7 6 What's the best way to loop through that array to do that? My thinking gets me to create a loop for 5 through 1, repeated twice, and the

Re: [PHP] Looping through array

2006-11-16 Thread Brad Bonkoski
Ashley M. Kirchner wrote: Say I have an array containing ten items, and I want to display them in a table as follows: 5 4 3 2 1 10 9 8 7 6 What's the best way to loop through that array to do that? My thinking gets me to create a loop for 5 through 1, repeated twice, and the

RE: [PHP] looping through array with list()/each()

2002-09-25 Thread Kevin Porter
Thank you, thank you, thank you. And, er, "D'oh!" :o) - Kev > -Original Message- > From: Karl Phillipson [SMTP:[EMAIL PROTECTED]] > Sent: 25 September 2002 12:13 > To: [EMAIL PROTECTED] > Subject: RE: [PHP] looping through array with list()/each(

RE: [PHP] looping through array with list()/each()

2002-09-25 Thread Karl Phillipson
while ( list($key, $val) = each($ser) ); <--- ; should not be here -Original Message- From: Kevin Porter [mailto:[EMAIL PROTECTED]] Sent: 25 September 2002 12:13 To: Kevin Porter; '[EMAIL PROTECTED]' Subject: RE: [PHP] looping through array with list()/each() I meant $ke

RE: [PHP] looping through array with list()/each()

2002-09-25 Thread Kevin Porter
I meant $key and $val of course :o) - Kev > -Original Message- > From: Kevin Porter [SMTP:[EMAIL PROTECTED]] > Sent: 25 September 2002 12:00 > To: '[EMAIL PROTECTED]' > Subject: [PHP] looping through array with list()/each() > > OK so I've done this hundreds of times, but this ti