php - How to get only numbers from last parentheses?

one text

Solution:

You could use a regex to search for digits in parentheses, using a negative lookahead to assert that there are no more parentheses after that number:

$string = "Mixing group (3pcs) (350) ";

preg_match('/\((\d+)\)(?!.*\(.*\))/', $string, $matches);
echo $matches[1];

Output:

350

Demo on 3v4l.org

Source