check if an array have one or more empty values

后端 未结 5 2262
无人共我
无人共我 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:22

    If you want to have a function which checks if a item in the array is false you could write your own function which does:

    • Iterates through the array
    • For each cycle check if current item value is ""
    • If the value is not "" run next cycle
    • If the value is "" break the loop by return False

    The array_filter takes a array and a function, then iterates through the array and sends in each item in the specified function. If the function returns true the the item is kept in the array and if the function returns false the item is taken out of the array.

    You see the difference, right?

提交回复
热议问题