Skip to content
Advertisement

How to do this in a for loop?

This is my html:

JavaScript

I want a for loop in php where there gets printed as many boxes as ‘x’ is. I have tried this:

JavaScript

But it’s not echoing anything, and also, how do I make sure they all have a different background color when I echo?

Advertisement

Answer

Store all colors in array and:

JavaScript

Also note usage of " and ' in echo.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement