Determine if all the values in a PHP array are null -


i'm looking performance friendly approach check if values in array null or if @ least has 1 element other types.

i.e. need method called containsonlynull($array), returns booleans according passed array

e.g. :

$a = containsonlynull([null,null,null,null,null]); $b = containsonlynull([null,null,1,null,null]);  // $a true // $b false 

any advice appreciated :)

function containsonlynull($input) {     return empty(array_filter($input, function ($a) { return $a !== null;})); } 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -