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:
test
for ($i=0;$i<5;$i++) {
$color = (( $coloralternator++ %2) ? "e0e0e0" : "ff6666");
echo "Hello everyone |
}
?>
http://www.bkjia.com/PHPjc/316593.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/316593.htmlTechArticleA 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, use the following method...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn