">

How to produce a chessboard pattern in PHP

This is a great lesson for those who want to learn more about nested loops and conditional statements. We produce a simple chessboard pattern.

In this lesson we will create a chessboard pattern, an 8x8 grid of black and white squares like this:

Want to Learn More?

Become a member and get access to the member only area of this site.

LEARN MORE

Comments

Your email address will not be published.

User Avatar

Super cool! I was given a similar task in a recent assignment and I struggled with getting the colours correct. However, I understand now!

by Dicey12, 27-Dec-2015

User Avatar

Glad this tutorial proved useful. There are many variations on this task with some nice little extension exercises such as colouring various squares in difference colours, producing multiplication grids, identifying multiples of numbers (for number grids) etc

by Patrick Morrow, 27-Dec-2015

PHP for Beginners

Would you like lifetime access to the hugely successful PHP for Beginners course? Click here to find out how.

FREE Code Snippets

FREE hints and tips delivered direct to you once per month.