A simple example of color rotation, using the ternary operator to make the program concise.
We have seen on the website that the background color of some table cells changes every other row. In fact, this can be achieved with the following small piece of code: $color=(($coloralter++ %2)? "e0e0e0": "e8e8e8"), that is, by accumulating variables and taking the remainder 2, using the ternary operator to obtain two different color values.
An example is as follows:
Hello everyone |