3v4l.org

run code in 300+ PHP versions simultaneously
<?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); }

preferences:
33.99 ms | 402 KiB | 5 Q