- var_dump: documentation ( source)
- preg_match: documentation ( source)
- str_replace: documentation ( source)
- preg_replace: documentation ( source)
<?php
$arr = ['foo' => [5 => 'bar', 10 => 'baz']];
$match = 'foo.{key}.bar';
$pattern = '/'.preg_replace('/\{(\w+?)\}/', '(.+)', str_replace('.', '\.', $match)).'/';
if (preg_match($pattern, $match, $matches)) {
var_dump($match);
}