Curious if anyone has a cool snippet or idea for how to accomplish the following:
/** * Select all of the keys matching a given key. Asterisks (*) * should be treated as wildcards and would match any string * similar to a regex expression: 'test_*_asdf' => 'test_.+_asdf' * * @param string $wild_key * @param array $array * @return array */ array_key_exists_wildcard($wild_key, $array);
Obviously it would be nice to just replace * with .+, but special characters could cause a problem, right? I also couldn’t come up with a graceful solution using explode.