Hi friends
basic question for the community
I want to generate a checkered flag but im unsure how to achieve this with for loops ?
each box is of side 40 and width over all = $n any help would be great thanks
$height = $n * 40;
$width = $height;
$im = imagecreatetruecolor($width, $height);
$white = imagecolorallocate($im, 255, 255, 255);
$red = imagecolorallocate($im, 255, 0, 0);
for($i = 0; $i <= $width; $i += 40)
{
for($j = 0; $j <= $n; $j += $n)
{
if(( $i + $j ) % 2 == 0)
{
imagefilledrectangle ( $im , 0, $j, 0 , $width , $red );
}
else
{
imagefilledrectangle ( $im , $j, $j , 0 , $width , $white );
}
}
}
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);