I just wrote two function they work perfectly
I would like to know what do u thing about them and how can we improve them together
thanx
// ------------------------------------------------------------------------
// alternate_2colors
// ------------------------------------------------------------------------
// Alternating colours with two colours
// * example
// <table cellpadding=0 cellspacing=0 border=0 width=100%>
// <?php
// include(\'html.php\'); html.php contains our function
// $t = 0;
// while($t < 10)
// {
// echo \'<TR BGCOLOR=\"\' . $cl = alternate_2colors(\'#EEEEEE\', \'#FFFFFF\', $t++). \'\"><td>\'. $t . \"</td></tr>\n\";
// }
// ?>
// <table>
function alternate_2colors($color_1, $color_2, $cpt)
{
$couleur = ($cpt % 2) ? $color_1 : $color_2;
return $couleur;
}
// ------------------------------------------------------------------------
// alternate_xcolors
// ------------------------------------------------------------------------
// Alternating colors with unlimited colors
// $colors Has to be an array
// $t is an incremented interger
// $z iz the maximum value that $t can take
//
// example
// <table cellpadding=0 cellspacing=0 border=0 width=100%>
// <? php
// include(\'html.php\'); html.php contains our function
// $colors = array();
// $colors[] = \"#EDEDED\";
// $colors[] = \"#CCCCCC\";
// $colors[] = \"#FFFFFF\";
// $colors[] = \"#FFFFDF\";
//
// $t = 0;
// while($t < 10)
// {
// echo \'<TR BGCOLOR=\"\' . $cl = alternate_Xcolors($colors,$t++,$t). \'\"><td>\'. $t . \"</td></tr>\n\";
// }
// ?>
// <table>
//
function alternate_Xcolors($colors, $t, $z)
{
$zb = floor($z/sizeof($colors));
$y = $z -($zb * sizeof($colors));
while ( $x < $zb )
{
foreach($colors as $col)
{
$colr[] = $col;
}
$x++;
}
for ($i = 0; $i <= $y-1; $i++)
{
$colr[] = $colors[$i];
}
return $colr[$t];
}