Without having to change the function signature, I'd like a PHP function to behave differently if given an associated array instead of a regular array.
Note: You can assume arrays are homogenous. E.g., array(1,2,"foo" => "bar")
is not accepted and can be ignored.
function my_func(Array $foo){
if (…) {
echo "Found associated array";
}
else {
echo "Found regular array";
}
}
my_func(array("foo" => "bar", "hello" => "world"));
# => "Found associated array"
my_func(array(1,2,3,4));
# => "Found regular array"
Is this possible with PHP?