I’m trying to filter an array, in which the filter function is supposed to check for multiple conditions. For example, if element x starts with a capital letter, the filter function should return true. Except, if the element before element x satisfies certain other conditions, then element x should not stay in the array and the filter function should therefore return false.
Problem is that the callback function in array_filter only passes the element’s value and not its key… doing some magic with array_search will probably work, but I was just wondering whether I’m looking in the wrong place for this specific issue?
Sounds like a case for a good old foreach loop: