Re: PHP Newbie Q, seperating even from odd in an array
| From: | bvr | Date: | Mon, 11 Feb 2002 18:57:58 +0000 |
| Subject: | Re: PHP Newbie Q, seperating even from odd in an array | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-84307@lists.php.net to get a copy of this message | ||
Two columns:
$values = file("blah.txt");
$nh = count($values) / 2; // we only need half the number of rows
// AND then
for ($i = 0; $i < $nh; $i++)
{
echo("<TR><TD>" . $values[$i] . "</TD><TD>" .
$values[$nh + $i] . "</TD></TR>\n");
}
// OR this
$j = 0;
for ($i = 0; $i < $nh; $i++)
{
echo("<TR><TD>" . $values[$j++] . "</TD><TD>" .
$values[$j++] . "</TD></TR>\n");
}
bvr.
On Mon, 11 Feb 2002 12:55:52 -0500, Chris Skinner wrote:
>Hi all,
>
>I am reading into an array from a text file, and when referencing, I would
>like to reference the even and odd counts of the array seperately. I am
>trying to split them up into two columns to more easily manage a list.
>
>Is there a call that allows -- > if $n = even {
>
>Thanks!
>
>--Chris
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
>