The foreach() function of array object execute given method once for each element of array. The filter method of array object will creates a new array with all of the elements of this array for which the provided filtering function returns true. Use it for example to test each element of the array.
Syntax
This will produce following result
This will produce following result