Description :
array_filter() function is used to apply a filter on array elements based on the function and returns the array with filtered elements, it accepts an array to be checked and a callback function. The callback function is used to validate the elements in the array.
array_filter(array, callbackfunction, flag)
The array_filter()
function accepts the following parameters.
Parameter | Description |
---|---|
array | Required. Specifies the array to filter. |
callback | Optional. Specifies the name of the callback function. |
flag |
Optional. Specifies what arguments are sent to callback:
Default is |
Given below example Find the positive number from given array of the numbers:
Output :
Array
(
[0] => 12
[1] => 30
[4] => 75
)