Skip to content

Instantly share code, notes, and snippets.

@Danack
Created October 13, 2015 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Danack/349e49e39e77ac1d5fb3 to your computer and use it in GitHub Desktop.
Save Danack/349e49e39e77ac1d5fb3 to your computer and use it in GitHub Desktop.
FilterBuildup
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