3
I have the following code that was taken from example #3 in the PHP documentation for the function 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));
Interestingly, when testing 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
See on the Ideone.
But in the documentation, the function is described as capable of accepting 3 parameters:
array array_filter ( array $array [, callable $callback [, int $flag = 0 ]] )
The third parameter is exactly why you were using this function to solve the problem.
Question
What’s happening so I can’t make use of the three parameters?
Version of PHP: 5.3.22 | Host: Linux | Server API: CGI/Fastcgi
I have encountered this problem once before and I have not found a solution
– Bruno Calza
Reading the documentation, it seems to be version problem. I added as an answer down there.
– Bruno Calza