Here is my array ouput
Array
(
    [1] => 1
    [2] => 2
    [3] =>  
)
How do I know the [3] => is empty?
foreach ($array as $key => $value) {
    if (empty($value))
        echo "$key empty <br/>";
    else
        echo "$key not empty <br/>";
}
My out put showing all is not empty. What is correct way to check is empty?
An other solution:
$array = array('one', 'two', '');
if(count(array_filter($array)) == count($array)) {
    echo 'OK';
} else {
    echo 'ERROR';
}
http://codepad.org/zF9KkqKl
It works as expected, third one is empty
http://codepad.org/yBIVBHj0
Maybe try to trim its value, just in case that third value would be just a space.
foreach ($array as $key => $value) {
    $value = trim($value);
    if (empty($value))
        echo "$key empty <br/>";
    else
        echo "$key not empty <br/>";
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With