Reputation:
Here i am having one array, using this array i have to get the index
like which having null or empty values,i goggled it but i am not getting my expected answer,kindly see below i have posted my expected answer.
print_r($val);
Array
(
[id] => 4 A
[tripID] =>
[startFrom] => 1
[limit] => 20
[cabID] =>
)
Expected answer
Upvotes: 1
Views: 228
Reputation: 31749
This should help -
$a = array
(
'ID' => '4 A',
'tripID' => '',
'startFrom' => 1,
'limit' => 20,
'cabID' => '',
);
// Filter array if value is blank or null but not 0
$check = array_filter($a, function($v) {
return $v == '' || $v == null;
});
// Extract the keys
print_r(array_keys($check));
Output
Array
(
[0] => tripID
[1] => cabID
)
Upvotes: 2
Reputation: 1126
This function should put you in the right direction array_filter. Seems like a homeworkey question, mind.
Upvotes: 0