PHP check value against multiple values with OR-operator

前端 未结 3 624
失恋的感觉
失恋的感觉 2020-11-30 13:11

I have a filename($fname) and I need to assign $pClass to the file type with a \"-\" afterwards. Currently I always get text-, no matt

3条回答
  •  猫巷女王i
    2020-11-30 13:49

    You can use in_array() to compare a value to multiple strings:

    if(in_array($ext, array('txt','rtf','log','docx')){
        // Value is found.
    }
    

提交回复
热议问题