+ 1
How to check multidimensional empty array in php? key exist and value empty
i have a large multidimensional array, it may have empty values if it has all empty values then i do not want to insert this data into database. how i can check before inserting into database?
2 Respuestas
+ 11
It would be great to see an example.
Generally speaking, you can do it by using foreach and empty($yourArray[$key]).
+ 3
$inputs = [
'id' => 123,
'last' => '',
'password' => '',
'email' => null
];
$filtered = array_filter($inputs, function ($key) {
return $key != '' || $key != null;
});
if(count($filtered) > 1){
echo "we will inserte into dbase";
}else{
echo "we will not insert into dbase";
}