$type=array("debit", "credit", "credit", "credit", "debit");
return ($finddebit == "debit");
$finaldebit = array_filter($type, 'filterDebit');
You can't quite get the sum that way because you aren't actually doing anything with the array of amounts, but you've already gotten pretty close.
You can use
array_intersect_key to find the entries in
$amount that match the keys in your filtered
echo array_sum(array_intersect_key($amount, $finaldebit));
If it's possible, I think it would be better to address this problem at some earlier point, so the two sets of associated values don't end up in separate arrays like this, especially if the two arrays came from a database, which would be able to handle this filtering/aggregation more efficiently, but since I don't know the source of the arrays, I don't have a suggestion for that.