Hi,
Here is the function which can take the $key as a RegEx/String. This function checks whether the given string($string) is a Regular Expression or not. If yes, it will use preg_match() function else it will use array_key_exists() function.
function preg_array_key_exists($filename, $array) {
$available = false;
if (array_key_exists($filename, $array))
{
$available = true;
}
else
{
$keys = array_keys($array);
foreach ($keys as $key) {
if (@preg_match($key, $filename) == 1) {
$available = true;
}
}
}
return $available;
}
Here is the function which can take the $key as a RegEx/String. This function checks whether the given string($string) is a Regular Expression or not. If yes, it will use preg_match() function else it will use array_key_exists() function.
function preg_array_key_exists($filename, $array) {
$available = false;
if (array_key_exists($filename, $array))
{
$available = true;
}
else
{
$keys = array_keys($array);
foreach ($keys as $key) {
if (@preg_match($key, $filename) == 1) {
$available = true;
}
}
}
return $available;
}