Skip to content

Instantly share code, notes, and snippets.

@alimranahmed
Created June 10, 2020 06:02
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 alimranahmed/31176f51f08f4741cc6b4ad6b637c264 to your computer and use it in GitHub Desktop.
Save alimranahmed/31176f51f08f4741cc6b4ad6b637c264 to your computer and use it in GitHub Desktop.
Scripts
<?php
function isMatched(string $pattern, string $value): bool
{
if ($pattern == $value) {
return true;
}
$pattern = preg_quote($pattern, '#');
$pattern = str_replace('\*', '.*', $pattern) . '\z';
return (bool)preg_match('#^' . $pattern . '#', $value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment