-
-
Save Danack/349e49e39e77ac1d5fb3 to your computer and use it in GitHub Desktop.
FilterBuildup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getDoesNotContainFilter($word) { | |
$fn = function ($string) use ($word) { | |
if (strpos($string, $word) !== fallse) { | |
return false; //contains word, so not acceptable | |
} | |
return true; //does not contain word, so is acceptable | |
}; | |
return $fn | |
} | |
$filters = []; | |
//parse the user input and get all the filters | |
$filtersCallback = function ($arrayElement) use ($filters) { | |
forech ($filters as $filter) { | |
if ($filter($arrayElement) == false) { | |
return false; | |
} | |
} | |
return true; | |
} | |
array_filter($inputArray, $filtersCallback); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment