Skip to content

Instantly share code, notes, and snippets.

View windbridges's full-sized avatar

alexey.d windbridges

View GitHub Profile
@irazasyed
irazasyed / gist:4340734
Created December 19, 2012 21:34
PHP: Match wildcard in string
function match_wildcard( $wildcard_pattern, $haystack ) {
$regex = str_replace(
array("\*", "\?"), // wildcard chars
array('.*','.'), // regexp chars
preg_quote($wildcard_pattern)
);
return preg_match('/^'.$regex.'$/is', $haystack);
}