I have the following code that was taken from example # 3 in the PHP documentation for array_filter()
:
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4);
var_dump(array_filter($arr, function($k) {
return $k == 'b';
}, ARRAY_FILTER_USE_KEY));
Curiously, when I tested this code to answer in this question , I got the following error:
Warning:
array_filter () expects at most 2 parameters, 3 given in /path/to/file.php on line X
View on Ideone .
But in the documentation, the function is described as being able to accept 3 parameters:
array array_filter ( array $array [, callable $callback [, int $flag = 0 ]] )
The third parameter is exactly why you were resorting to this function to solve the problem.
Question
What is happening to not being able to use the three parameters?
PHP version: 5.3.22 | Host: Linux | Server API: CGI / FastCGI