The array_filter() function passes each value/element of an array to user defined function, and return true or false and return any array value only that is true.
array_filter(array,user_defined_function) the function take two parameters and both are required.
First is an array and second is user defined function.
2. function user_Defined($array)
4. if ($array==="Rizwan")
6. return true;
8. return false;
Array (  => Rizwan )
On line 10 we have declared $names array and initialize it. On line 11 we have passed it to array_filter function of php. The array_filter function of php has two parameters first is array and second is user defined function. That passes through an array and returns the array value only that is true in user defined function.
Filter Arrays Using array_filter() in PHP