It is my first time coding in PHP. I am trying to return an array which contains of the amount of each type of cash
public function test($a){
$a = [];
$cash = array(
'20' => 0,
'30' => 0,
'40' => 0,
'50' => 0,
'60' => 0,
'70' => 0,
'80' => 0,
);
foreach($a as $k => $v) {
if (array_key_exists("$k",$cash) && $v!= null ) {
$cash[$k] += 1;
}
}
return $cash;
}
When I try testing the code I get the error: Invalid argument supplied for foreach()