Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Created October 13, 2020 15:43
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/e1c0613dfea82e2daf0dec555bddf0f4 to your computer and use it in GitHub Desktop.
Save lbvf50mobile/e1c0613dfea82e2daf0dec555bddf0f4 to your computer and use it in GitHub Desktop.
Just PHP FUN 127.
<?php
# https://www.codewars.com/kata/58291fea7ff3f640980000f9 Coding Meetup #8 - Higher-Order Functions Series - Will all continents be represented?
function all_continents(array $a): bool {
$must_be = ['Africa', 'Americas', 'Asia', 'Europe', 'Oceania'];
$current_arr = array_map(function($x){ return $x['continent'];},$a);
$current = array_count_values($current_arr);
foreach($must_be as $val) if(false == isset($current[$val])) return false;
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment