array_filter — Filters elements of an array using a callback function
Description
array_filter(array $array, ?callable $callback = null, int $mode = 0): array
Iterates over each value in the array passing them to the callback function. If the callback function returns true, the current value from array is returned into the result array.
Array keys are preserved, and may result in gaps if the array was indexed. The result array can be reindexed using the array_values() function.
Parameters
array
The array to iterate over
callback
The callback function to use
If no callback is supplied, all empty entries of array will be removed. See empty() for how PHP defines empty in this case.
mode
Flag determining what arguments are sent to callback:
ARRAY_FILTER_USE_KEY - pass key as the only argument to callback instead of the value
ARRAY_FILTER_USE_BOTH - pass both value and key as arguments to callback instead of the value
Default is 0 which will pass value as the only argument to callback instead.
On this page of the site you can watch the video online array filter with a duration of hours minute second in good quality, which was uploaded by the user PHPeasy 20 December 2022, share the link with friends and acquaintances, this video has already been watched 13 times on youtube and it was liked by 0 viewers. Enjoy your viewing!