Simpler way to check if variable is not equal to multiple string values?

前端 未结 7 1250
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-04 19:11

Current Codes:



        
相关标签:
7条回答
  • 2020-12-04 19:52

    Some basic regex would do the trick nicely for $some_variable !== 'uk' && $some_variable !== 'in':

    if(!preg_match('/^uk|in$/', $some_variable)) {
        // Do something
    }
    
    0 讨论(0)
提交回复
热议问题