Technology Temerity

Wig Wag

PHP

This super simple function will output alternating values as the input numeric increments. Handy for server side table styling, progress bars, and other minor elements where an alternating visual style is desirable.

License

Use

During any loop statement where row outputs are created, pass the loop or row count to this function. The resulting output should then be used as your style argument.

Source Code

// 	Damon Vaughn Caskey
//	2012-10-18
//	Output alternating values for even/odd input. 
//
// $i Number to evaluate.
// $even: Output if $i is an even number. 
// $odd: Output if $i is an odd number.
function wig_wag($i, $even = "#DDDDFF", $odd = "#CECEFF") 
{ 
	$result = NULL; // Final result.
	 
	if($i%2) //Even number? 
	{		
		$result = $even; // Set even value. 
	} 
	else 
	{ 
		$result = $odd; // Set odd value. 
	}
	
	// Output result.
	return $result;
}

Author: Damon Caskey

Hello all, Damon Caskey here - the esteemed owner of this little slice of cyberspace. Welcome!

Leave a Reply