添加参数的功能不起作用

时间:2018-11-20 02:19:44

标签: php regex wordpress

我对以下代码有疑问。

当我将函数与诸如sum_warehouses_stock("CALL", "2", "B", "10", "CALL", 1 )之类的参数一起使用时,它返回零而不是加数字。我忽略了什么吗?

function sum_warehouses_stock(){

    $total = 0;
    $warehouses = func_get_args();

    foreach($warehouses as $warehouse){
    $warehouse = str_replace(["+","<",">","B"], "", $warehouse);
        if (is_numeric($warehouse)){
             $total += $warehouse;
        }
     }
     return $total;
}

0 个答案:

没有答案