Check if Variable exists and === true

前端 未结 4 1056
谎友^
谎友^ 2020-12-07 00:52

I want to check if:

  • a field in the array isset
  • the field === true

Is it possible to check this with one if statement?

4条回答
  •  抹茶落季
    2020-12-07 01:20

    I think this should do the trick ...

    if( !empty( $arr['field'] ) && $arr['field'] === true ){ 
        do_something(); 
    }
    

提交回复
热议问题