从php中的字符串中提取十进制或整数

shy*_*mtp 0 php

例如:

$str .= "Additional tax(2.34)";
$str .= "Additional tax(3)";
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮助我从字符串中提取数字.我需要这样的数组格式

Array ( [0] => 2.34 [1] => 3 );
Run Code Online (Sandbox Code Playgroud)

Sea*_*ght 7

这应该这样做:

<?php
    $str = '';
    $str .= "Additional tax(2.34)";
    $str .= "Additional tax(3)";

    if (preg_match_all('/\((\d+(?:\.\d+)?)\)/', $str, $matches) > 0) {
        var_dump($matches[1]);
    }
?>
Run Code Online (Sandbox Code Playgroud)