[PHP-users 13284] for などのループの中にifを入れる事は可能なのでしょうか?
php
php-users@php.gr.jp
Fri, 14 Feb 2003 21:26:38 +0900
以前ここでpoqだった者です。こんばんは。
スケジュールリストで、項目が空欄の場合は表示せず、表示した日に値が入って
いればボールドで表示させるというスクリプトを作成したのですが、
どうもforなどのループ処理でソースを短く出来るのではないのかと
思われるのですが、if文を入れるとなるとどう処理して良いのか
手元の資料などを読んでも分かりません。
アドバイス頂けないでしょうか?
------------------------------------------------------------------
<?php
$time = date ("d");
$d01d = "01日(土):<font color=\"red\">臨時休業</font>";
$d02d = "";
$d03d = "";
$d04d = "";
$d05d = "";
$d06d = "";
$d07d = "";
$d08d = "08日(土):<font color=\"red\">休み</font>";
$d09d = "09日(日):<font color=\"red\">休み</font>";
$d10d = "11日(火):<font color=\"red\">建国記念日</font>";
$d11d = "";
$d12d = "";
$d13d = "";
$d14d = "";
$d15d = "";
$d16d = "";
$d17d = "";
$d18d = "18日(火):会長講話";
$d19d = "";
$d20d = "";
$d21d = "";
$d22d = "";
$d23d = "";
$d24d = "";
$d25d = "25日(火):社員集会";
$d26d = "";
$d27d = "";
$d28d = "";
$d29d = "";
$d30d = "";
$d31d = "";
if (($time == "01") and ( $d01d !="")){
print ("<b>$d01d</b><br>\n");} else if($d01d != ""){print ("$d01d<br>\n");}
if (($time == "02") and ( $d02d !="")){
print ("<b>$d02d</b><br>\n");} else if($d02d != ""){print ("$d02d<br>\n");}
if (($time == "03") and ( $d03d !="")){
print ("<b>$d03d</b><br>\n");} else if($d03d != ""){print ("$d03d<br>\n");}
if (($time == "04") and ( $d04d !="")){
print ("<b>$d04d</b><br>\n");} else if($d04d != ""){print ("$d04d<br>\n");}
if (($time == "05") and ( $d05d !="")){
print ("<b>$d05d</b><br>\n");} else if($d05d != ""){print ("$d05d<br>\n");}
if (($time == "06") and ( $d06d !="")){
print ("<b>$d06d</b><br>\n");} else if($d06d != ""){print ("$d06d<br>\n");}
if (($time == "07") and ( $d07d !="")){
print ("<b>$d07d</b><br>\n");} else if($d07d != ""){print ("$d07d<br>\n");}
if (($time == "08") and ( $d08d !="")){
print ("<b>$d08d</b><br>\n");} else if($d08d != ""){print ("$d08d<br>\n");}
if (($time == "09") and ( $d09d !="")){
print ("<b>$d09d</b><br>\n");} else if($d09d != ""){print ("$d09d<br>\n");}
if (($time == "10") and ( $d10d !="")){
print ("<b>$d10d</b><br>\n");} else if($d10d != ""){print ("$d10d<br>\n");}
if (($time == "11") and ( $d11d !="")){
print ("<b>$d11d</b><br>\n");} else if($d11d != ""){print ("$d11d<br>\n");}
if (($time == "12") and ( $d12d !="")){
print ("<b>$d12d</b><br>\n");} else if($d12d != ""){print ("$d12d<br>\n");}
if (($time == "13") and ( $d13d !="")){
print ("<b>$d13d</b><br>\n");} else if($d13d != ""){print ("$d13d<br>\n");}
if (($time == "14") and ( $d14d !="")){
print ("<b>$d14d</b><br>\n");} else if($d14d != ""){print ("$d14d<br>\n");}
if (($time == "15") and ( $d15d !="")){
print ("<b>$d15d</b><br>\n");} else if($d15d != ""){print ("$d15d<br>\n");}
if (($time == "16") and ( $d16d !="")){
print ("<b>$d16d</b><br>\n");} else if($d16d != ""){print ("$d16d<br>\n");}
if (($time == "17") and ( $d17d !="")){
print ("<b>$d17d</b><br>\n");} else if($d17d != ""){print ("$d17d<br>\n");}
if (($time == "18") and ( $d18d !="")){
print ("<b>$d18d</b><br>\n");} else if($d18d != ""){print ("$d18d<br>\n");}
if (($time == "19") and ( $d19d !="")){
print ("<b>$d19d</b><br>\n");} else if($d19d != ""){print ("$d19d<br>\n");}
if (($time == "20") and ( $d20d !="")){
print ("<b>$d20d</b><br>\n");} else if($d20d != ""){print ("$d20d<br>\n");}
if (($time == "21") and ( $d21d !="")){
print ("<b>$d21d</b><br>\n");} else if($d21d != ""){print ("$d21d<br>\n");}
if (($time == "22") and ( $d22d !="")){
print ("<b>$d22d</b><br>\n");} else if($d22d != ""){print ("$d22d<br>\n");}
if (($time == "23") and ( $d23d !="")){
print ("<b>$d23d</b><br>\n");} else if($d23d != ""){print ("$d23d<br>\n");}
if (($time == "24") and ( $d24d !="")){
print ("<b>$d24d</b><br>\n");} else if($d24d != ""){print ("$d24d<br>\n");}
if (($time == "25") and ( $d25d !="")){
print ("<b>$d25d</b><br>\n");} else if($d25d != ""){print ("$d25d<br>\n");}
if (($time == "26") and ( $d26d !="")){
print ("<b>$d26d</b><br>\n");} else if($d26d != ""){print ("$d26d<br>\n");}
if (($time == "27") and ( $d27d !="")){
print ("<b>$d27d</b><br>\n");} else if($d27d != ""){print ("$d27d<br>\n");}
if (($time == "28") and ( $d28d !="")){
print ("<b>$d28d</b><br>\n");} else if($d28d != ""){print ("$d28d<br>\n");}
if (($time == "29") and ( $d29d !="")){
print ("<b>$d29d</b><br>\n");} else if($d29d != ""){print ("$d29d<br>\n");}
if (($time == "30") and ( $d30d !="")){
print ("<b>$d30d</b><br>\n");} else if($d30d != ""){print ("$d30d<br>\n");}
if (($time == "31") and ( $d31d !="")){
print ("<b>$d31d</b><br>\n");} else if($d31d != ""){print ("$d31d<br>\n");}
?>