时间:2021-07-01 10:21:17 帮助过:17人阅读
Php代码
function getPartsNum($jsonStr){
$total = 0;
if( $jsonStr && ($jsonStr != 'NAN') && ($jsonStr != '[]') ) {
$detail = json_decode($jsonStr);
if(is_array($detail)){//或foreach ( (array)$detail as $d)
foreach ($detail as $d){
$total += $d->num;
}
}
}
return $total;
}