if문에서 조건을 간단하게 하고싶습니다.
다음 if문에서 조건을 최대한 간단히 할수 있을까요?
도움을 부탁드립니다.
<?
for ($i=0; $i<count($list); $i++)
{
....
$a="free,member,aaa,bbb,ccc,ddd,...";
$a1 = explode(",",$a);
if($list[$i][bo_table] == $a1[0] || $list[$i][bo_table] == $a1[1] || $list[$i][bo_table] == $a1[2] || $list[$i][bo_table] == $a1[3] || $list[$i][bo_table] == $a1[4] || $list[$i][bo_table] == $a1[5] || ... ) {
...
}
}
?>
도움을 부탁드립니다.
<?
for ($i=0; $i<count($list); $i++)
{
....
$a="free,member,aaa,bbb,ccc,ddd,...";
$a1 = explode(",",$a);
if($list[$i][bo_table] == $a1[0] || $list[$i][bo_table] == $a1[1] || $list[$i][bo_table] == $a1[2] || $list[$i][bo_table] == $a1[3] || $list[$i][bo_table] == $a1[4] || $list[$i][bo_table] == $a1[5] || ... ) {
...
}
}
?>
|
댓글을 작성하시려면 로그인이 필요합니다.
로그인
댓글 2개
foreach( $a1 as $temp){
if($list[$i][bo_table] == $temp){
$flag=1;
}
}
if($flag==1)
~~~~~~
이런식으로 하시면 될것 같기도 한데요?
http://kr2.php.net/manual/kr/control-structures.foreach.php
를 참조해보세요..