Check if List Is Empty in PHP
array empty check in php
if (empty($array)) {
// list is empty.
}
php check if all array values are not empty
// You can write a function to do this.
function valid(array $array) {
# Do this if you expect array("key"=>"value")
foreach ($array as $key=>$value) {
if (!isset($key) && empty($value) {
return false;
}
}
return true;
}
function valid(array $array) {
# Do this if you expect array("value", "value2")
foreach ($array as $value) {
if (empty($value) {
return false;
}
}
return true;
}