判断是否为空
if (!$cart_num || !$cart_info) return [];
数组循环
$compute_arr = ['coupon_price', 'integral_price', 'postage_price', 'use_integral', 'one_brokerage', 'two_brokerage', 'sum_true_price']; foreach ($compute_arr as $field) { if (!isset($cart_info[$field]) || !$cart_info[$field] || $is_gift) { $new_cart_info[$field] = 0; continue; } $scale = 2; if ($field == 'use_integral') $scale = 0; if (!$i) {//拆出 $new_cart_info[$field] = bcmul((string)$cart_num, bcdiv((string)$cart_info[$field], (string)$cart_info['cart_num'], 4), $scale); } else { $field_number = bcmul((string)bcsub((string)$cart_info['cart_num'], (string)$cart_num, 0), bcdiv((string)$cart_info[$field], (string)$cart_info['cart_num'], 4), $scale); $new_cart_info[$field] = bcsub((string)$cart_info[$field], (string)$field_number, $scale); } }
数组长度
$data['uid'].count()
不等于
if($count !==$data['uid'].count()) { }
字符串已逗号分隔为数组
explode(',', $data['uid'])
判断变量是否为数组
is_array($env)
标签:info,scale,string,cart,语法,field,num,php From: https://www.cnblogs.com/use-D/p/16588426.html