How do i check if all keys in an array have empty values in PHP?

Your assumption is incorrect. array('key1', 'key2', 'key3', 'key4') has 4 values and keys in the range 0..3.

array('key1', 'key2' => value2, 'key3', 'key4' => value4) has the value key1 (with key 0), the key key2, the value key3 (with key 1) and the key key4.


Assuming you actually mean an array like

array('key1' => null, 'key2' => null, 'key3' => null, 'key4' => null)

the answer is simply

if (!array_filter($array)) {
    // all values are empty (where "empty" means == false)
}

Tags:

Php

Arrays