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
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,
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
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
$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
If you know the array elements, you may not need to loop. Why not just echo
the particular array elements i.e. for
example?
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
';
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,
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
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
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(
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
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
13 matches
Mail list logo