動作する次のphpコードがありますが、長すぎて読むのが面倒です...
// get the row
if ($taktArticle[0]['t1position3'] > 3 AND $taktArticle[0]['t1position3'] < 7 ) {
$row = "row1";
}
if ($taktArticle[0]['t1position3'] > 7 AND $taktArticle[0]['t1position3'] < 12 ) {
$row = "row2";
}
if ($taktArticle[0]['t1position3'] > 12 AND $taktArticle[0]['t1position3'] < 17 ) {
$row = "row3";
}
if ($taktArticle[0]['t1position3'] > 17 AND $taktArticle[0]['t1position3'] < 22 ) {
$row = "row4";
}
if ($taktArticle[0]['t1position3'] > 22 AND $taktArticle[0]['t1position3'] < 27 ) {
$row = "row5";
}
// get the columns
if ($taktArticle[0]['t1position3'] == 3
or $taktArticle[0]['t1position3'] == 8
or $taktArticle[0]['t1position3'] == 13
or $taktArticle[0]['t1position3'] == 18
or $taktArticle[0]['t1position3'] == 23) {
$col = "col1";
}
if ($taktArticle[0]['t1position3'] == 4
or $taktArticle[0]['t1position3'] == 9
or $taktArticle[0]['t1position3'] == 14
or $taktArticle[0]['t1position3'] == 19
or $taktArticle[0]['t1position3'] == 24) {
$col = "col2";
}
if ($taktArticle[0]['t1position3'] == 5
or $taktArticle[0]['t1position3'] == 10
or $taktArticle[0]['t1position3'] == 15
or $taktArticle[0]['t1position3'] == 20
or $taktArticle[0]['t1position3'] == 25) {
$col = "col3";
}
if ($taktArticle[0]['t1position3'] == 6
or $taktArticle[0]['t1position3'] == 11
or $taktArticle[0]['t1position3'] == 16
or $taktArticle[0]['t1position3'] == 21
or $taktArticle[0]['t1position3'] == 26) {
$col = "col4";
}
if ($taktArticle[0]['t1position3'] == 7
or $taktArticle[0]['t1position3'] == 12
or $taktArticle[0]['t1position3'] == 17
or $taktArticle[0]['t1position3'] == 22
or $taktArticle[0]['t1position3'] == 27) {
$col = "col5";
}
さて... これを ($taktArticle[0]['t1position3'] から ($taktArticle[0]['t1position11']) まで繰り返さなければなりません
ご存じのとおり、コードは巨大になります...このコードを短縮する方法を知っている人はいますか?
よろしく、ジョン