strip()并获得价值

I have a html list that looks like this:

  • animals (45)
  • houses (36)
  • computers (96)

I want to get all the values inside those () and make like $sum = 45+36+96;

How can I do that? Thanks

assuming that the html content is already in a php variable like $list,

preg_match_all('{<li>[a-zA-Z\s]*\s\(([0-9]*)\)</li>}', $list, $matches);
$sum = array_sum($matches[1]);

for <li><span><a href="">, you can modify the regex to something like

preg_match_all('{<li>(["=a-zA-Z<>\s]*)\s\(([0-9]*)\)([/a-zA-Z<>\s]*)</li>}', 
   $list, $matches);
$sum = array_sum($matches[2]);

Given any string, this will match and sum all the numeric values between parenthesis:

preg_match_all('|\((\d+)\)|', $str, $matches);
$sum = array_sum($matches[1]);