[英]How do I change the background-color of a value depending on what it is through a .php file?
I have a line of code that currently works like this: 我有一行当前可以这样工作的代码:
$dimension = '<span style="background-color: #FFFF00"> T='.$thickness.'</span> X='.$x.' Y='.$y;
As you can see the value $thickness
Is highlighted yellow. 如您所见,值$thickness
黄色突出显示。 However $thickness
is a value that changes to the following values: 1.90, 1.50, and 1.15. 但是, $thickness
是一个更改为以下值的值:1.90,1.50和1.15。
How would I make each value have it's own background color? 如何使每个值都有其自己的背景色?
Example= 1.90 = Yellow, 1.50 = Green, 1.15 = Blue. 示例= 1.90 =黄色,1.50 =绿色,1.15 =蓝色。
$color = 'white';
if($thickness > 1.15) { $color = 'blue'; }
if($thickness > 1.5) { $color = 'green'; }
if($thickness > 1.9) { $color = 'yellow'; }
$dimension = '<span style="background-color: '.$color.'"> T='.$thickness.'</span> X='.$x.' Y='.$y;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.