3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = [ 'the(crow)bar', 'foo()bar', 'handlebar()', '()foofighters', '(foobar)', '()', 'barfood', 'barf(oo', 'fooeybar)', ')foob(', ]; $result = []; foreach ($strings as $string) { $result[$string] = preg_match('~\(([^)]+)\)~', $string, $match) ? $match[1] : ''; } var_export($result);

preferences:
36.38 ms | 405 KiB | 5 Q