- preg_replace_callback: documentation ( source)
- print_r: documentation ( source)
<?php
$s="a(bcdefghijkl(mno)p)q";
$return = preg_replace_callback(
'|(\((.+)\))+|',
function ($matches) {
return $matches[2];
},
$s
);
print_r($return);