我对以下代码有疑问。
当我将函数与诸如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;
}