> $l_iSecond = ($l_iMod < 2 ? $l_iHigh - $l_iMod : $l_iHigh); This should actually be:
$l_iSecond = ($l_iMod == 1 ? $l_iHigh - $l_iMod : $l_iHigh); but it works both ways. -- Matt Grimm Web Developer The Health TV Channel, Inc. (a non - profit organization) 3820 Lake Otis Parkway Anchorage, AK 99508 907.770.6200 ext. 686 907.336.6205 (fax) E-mail: [EMAIL PROTECTED] Web: www.healthtvchannel.org "Matt Grimm" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Try this: > > // Populate an array of random length > for ($i = 0; $i < rand(300, 600); $i++) { > $l_aTest[] = '...'; > } > $l_iLength = count($l_aTest); > $l_iLow = floor($l_iLength / 3); > $l_iHigh = ceil($l_iLength / 3); > $l_iMod = $l_iLength % 3; > > $l_iFirst = $l_iHigh; > $l_iSecond = ($l_iMod < 2 ? $l_iHigh - $l_iMod : $l_iHigh); > $l_iThird = $l_iLow; > > echo "<p><strong>Your columns are: $l_iFirst, $l_iSecond, > $l_iThird</strong></p>"; > > -- > Matt Grimm > Web Developer > The Health TV Channel, Inc. > (a non - profit organization) > 3820 Lake Otis Parkway > Anchorage, AK 99508 > 907.770.6200 ext. 686 > 907.336.6205 (fax) > E-mail: [EMAIL PROTECTED] > Web: www.healthtvchannel.org > > > "Dareal Hamsta" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > [ Please copy me off list. ] > > > > Say I have 7 items of data and I wish to sort them into 3 columns in a > HTML > > table. The items are unevenly sized, so rather than print them out in > rows - > > resulting in lots of wasteful whitespace - I would like to output them in > > vertical order. However if I use the modulus operator to check for when to > > break into a new column... > > > > foreach ($items as $item) { > > $counter++; > > if ( ($counter % $columns) == 0) { > > print "</td><td>"; > > } > > } > > > > ...the output will be something like this... > > > > +-------+-------+-------+ > > | Item1 | Item4 | Item7 | > > | Item2 | Item5 | | > > | Item3 | Item6 | | > > +-----------------------+ > > > > ...when what I'm really looking for is this... > > > > +-------+-------+-------+ > > | Item1 | Item4 | Item6 | > > | Item2 | Item5 | Item7 | > > | Item3 | | | > > +-----------------------+ > > > > Obviously if the number of items and columns are static, I have no > problem, > > but how do I get a layout that appeals to people and not computers if > > they're dynamic? This has me befuddled, I'm wondering is there an > algorithm > > for doing it or is it effectively a Turing Test. > > > > Thanks, > > adam > > > > > > <?php > > $s=array(74,65,112,104,112,72,32,59,45,41); > > for($i=0;$i<count($s);$i++){echo'&#'.$s[$i].';';} > > ?> > > > > _________________________________________________________________ > > MSN 8 with e-mail virus protection service: 2 months FREE* > > http://join.msn.com/?page=features/virus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php