- preg_match_all: documentation ( source)
- var_export: documentation ( source)
<?php
$string = "($a * 10 + $b) Euro and (10 + 2) cents";
$regex = '#\((([^()]+|(?R))*)\)#';
if (preg_match_all($regex, $string ,$matches)) {
echo var_export($matches[1], true);
} else {
//no parenthesis
echo $string;
}