php实现彩票走势图组选图用颜色区分

找了好久都没有关于这个的东西,我也是一步一步从百度知道上问出思路来的

$xxx = $row[‘bai‘] ;
$yyy = $row[‘shi‘] ;
$zzz = $row[‘ge‘] ;
$zuxuan = array ("$xxx" , "$yyy" , "$zzz");

if (in_array ("1",$zuxuan)) {
$a=0;
foreach($zuxuan as $value){
if($value=="1")
$a++;
}
if ($a==1) {echo "<td>" . ‘1‘ . "</td>";}
if ($a==2) {echo "<td class = ‘blue‘>" . ‘1‘ . "</td>";}
if ($a==3) {echo "<td class = ‘red‘>" . ‘1‘ . "</td>";}
} else echo "<td>" . ‘&nbsp;‘ . "</td>";

if (in_array ("2",$zuxuan)) {
$a=0;
foreach($zuxuan as $value){
if($value=="2")
$a++;
}
if ($a==1) {echo "<td>" . ‘2‘ . "</td>";}
if ($a==2) {echo "<td class = ‘blue‘>" . ‘2‘ . "</td>";}
if ($a==3) {echo "<td class = ‘red‘>" . ‘2‘ . "</td>";}
} else echo "<td>" . ‘&nbsp;‘ . "</td>";
if (in_array ("3",$zuxuan)) {
$a=0;
foreach($zuxuan as $value){
if($value=="3")
$a++;
}
if ($a==1) {echo "<td>" . ‘3‘ . "</td>";}
if ($a==2) {echo "<td class = ‘blue‘>" . ‘3‘ . "</td>";}
if ($a==3) {echo "<td class = ‘red‘>" . ‘3‘ . "</td>";}
} else echo "<td>" . ‘&nbsp;‘ . "</td>";
if (in_array ("4",$zuxuan)) {
$a=0;
foreach($zuxuan as $value){
if($value=="4")
$a++;
}
if ($a==1) {echo "<td>" . ‘4‘ . "</td>";}
if ($a==2) {echo "<td class = ‘blue‘>" . ‘4‘ . "</td>";}
if ($a==3) {echo "<td class = ‘red‘>" . ‘4‘ . "</td>";}
} else echo "<td>" . ‘&nbsp;‘ . "</td>";
if (in_array ("5",$zuxuan)) {
$a=0;
foreach($zuxuan as $value){
if($value=="5")
$a++;
}
if ($a==1) {echo "<td>" . ‘5‘ . "</td>";}
if ($a==2) {echo "<td class = ‘blue‘>" . ‘5‘ . "</td>";}
if ($a==3) {echo "<td class = ‘red‘>" . ‘5‘ . "</td>";}
} else echo "<td>" . ‘&nbsp;‘ . "</td>";
if (in_array ("6",$zuxuan)) {
$a=0;
foreach($zuxuan as $value){
if($value=="6")
$a++;
}
if ($a==1) {echo "<td>" . ‘6‘ . "</td>";}
if ($a==2) {echo "<td class = ‘blue‘>" . ‘6‘ . "</td>";}
if ($a==3) {echo "<td class = ‘red‘>" . ‘6‘ . "</td>";}
} else echo "<td>" . ‘&nbsp;‘ . "</td>";

我这里是用的1-6,还可以是1-任何,方法比较笨,但能实现相同的结果,如果有高手看到,请帮我改成一个更好的办法实现

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。