Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Last active September 25, 2020 12:26
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 lbvf50mobile/8c22dac9ae95894626c0fa51fc89c66b to your computer and use it in GitHub Desktop.
Save lbvf50mobile/8c22dac9ae95894626c0fa51fc89c66b to your computer and use it in GitHub Desktop.
Just PHP FUN 112.
<?php
# https://www.codewars.com/kata/523a86aa4230ebb5420001e1 Where my anagrams at?
function anagrams(string $word, array $words): array {
$histogram = count_chars($word,1);
$compare = function($substr) use ($histogram){
return $histogram == count_chars($substr,1);
};
return array_values(array_filter($words,$compare));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment