I built this function in PHP so far called removeAllValuesMatching, but I cannot seem to get it working. I am passing in two parameters $arr and $value. Not sure why this is happening. Any help would be greatly appreciated. This is what I have so far:
<?php
$arr = array(
'a' => "one",
'b' => "two",
'c' => "three",
'd' => "two",
'e' => "four",
'f' => "five",
'g' => "three",
'h' => "two"
);
function removeAllValuesMatching($arr, $value){
foreach ($arr as $key => $value){
if ($arr[$key] == $value){
unset($arr[$key]);
}
}
return $arr = array_values($arr);
}
print_r(removeAllValuesMatching($arr, "two"));
?>