Input:
Array
(
[ADDRESS CHECK FAILED, ADDRESS DISCREPANCY] => 716
[SSN CHECK FAILED, DOB CHECK FAILED] => 15
[DOB CHECK FAILED] => 139
[NO ISSUES] => 189
[DOB CHECK FAILED, ADDRESS DISCREPANCY] => 51
[DOB CHECK FAILED, ADDRESS CHECK FAILED, ADDRESS DISCREPANCY] => 23
[SSN CHECK FAILED] => 3
[ADDRESS DISCREPANCY] => 33
)
I need to sum the value of any key that does not contain the phrase "SSN CHECK FAILED"
I am using this function:
function in_array_r($needle, $haystack, $strict = true) {
foreach ($haystack as $item) {
if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && in_array_r($needle, $item, $strict))) {
return true;
}
}
return false;
}
Like this:
foreach ($issues_totals as $key => $value){
if (!in_array_r("SSN CHECK FAILED", $key)){
$total_with_no_issue += $value;
}
}
Where $issues_totals
is the above array and $total_with_no_issue
is the value I am looking for. The problem is that with this code $total_with_no_issue
is returning 1169, which is the total of the entire array. I want it to return 1151.
Any help is appreciated!