我有以下 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']
如您所知,代码将变得庞大...有人知道如何缩短此代码吗?
问候,约翰