check if an array have one or more empty values

后端 未结 5 2271
无人共我
无人共我 2021-02-19 11:34

I have the array $var, and I\'d like to return FALSE if one or more element in the array are empty (I mean, the string are \"\").

I think that array_filter()

5条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-19 12:09

    If you really want to check if one or more empty strings exists, it's simple. You can do,

    in_array('', $var, true);
    

    It returns true if empty string('') exists in at-least any one of the array values, false otherwise. You can refer this similar question too, how to check if an array has value that === null without looping?

提交回复
热议问题