채택완료

php배열 else if문 코드간소화

2018-08-01 (수) 18:54:36 2,799
Copy
$tableList = ['notice','event','cs','aft','media','rss'];

//중략

<?php }else if( $bo_table==$tableList[0] || $bo_table==$tableList[1] || $bo_table==$tableList[2] || $bo_table==$tableList[3] || $bo_table==$tableList[4] || $bo_table==$tableList[5]){ ?>

코드 어떻게 줄일수있을까요..

|

답변 1개 / 댓글 1개

채택된 답변
+20 포인트
Copy
if (in_array($bo_table, $tableList)) {

    // true

}

답변에 대한 댓글 1개

감사합니다

답변을 작성하려면 로그인이 필요합니다.