Skip to content

Instantly share code, notes, and snippets.

@mcsee
Last active December 24, 2023 15:57
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 mcsee/e0db739062069689de3efcd018192e39 to your computer and use it in GitHub Desktop.
Save mcsee/e0db739062069689de3efcd018192e39 to your computer and use it in GitHub Desktop.
<?
function simplify(array $patterns): array {
return array_values(array_filter($patterns,
function ($outerPattern) use ($patterns) {
foreach ($patterns as $innerPattern) {
if ($outerPattern != $innerPattern &&
substr_compare(
$outerPattern,
$innerPattern,
0,
strlen($innerPattern),
true)
=== 0) {
return false;
}
}
return true;
}));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment