$start_x = 15; $start_y = 90; $size = 15; for ($i = 0; $i < $this->totLen; $i++) { for ($j = 0; $j < $this->totWid; $j++) { imagerectangle( $im, $start_x + $i * $size + $i + 1, $start_y + $j * $size + $j + 1, $start_x + $i * $size + $i + $size, $start_y + $j * $size + $j + $size, $color_black /*imagecolorallocate($im, $i, $i, $i)*/ ); //* if ($this->coordinate[$i][$j] == '[Empty Seat]') { // fill this seat with the empty seat color imagefilledrectangle( $im, $start_x + $i * $size + $i+2, $start_y + $j * $size + $j+2, $start_x + $i * $size + $size, $start_y + $j * $size + $size, $color_green ); } elseif($this->coordinate[$i][$j] == '[Reserved Seat]') { //* imagefilledrectangle( $im, ($start_x+3) + $i * $size, ($start_y+2) + $j * $size, ($start_x+0) + $i * $size + $size, ($start_y-1) + $j * $size + $size, $color_red );//*/ } //*/ } } imagepng($im, "image.png"); imagedestroy($im);