How do I check if array value is empty?

前端 未结 8 1727
天命终不由人
天命终不由人 2020-12-09 04:03

Here is my array ouput

Array
(
    [1] => 1
    [2] => 2
    [3] =>  
)

How do I know the [3] => is empty?

8条回答
  •  粉色の甜心
    2020-12-09 04:37

    im using in my project like this for check this array

    im posting form data like this array('username' => 'john','surname' => 'sins');

    public function checkArrayKeyExist($arr) {
        foreach ($arr as $key => $value) {
            if (!strlen($arr[$key])) {
                return false;
            }
        }
        return true;
    }
    

提交回复
热议问题