在网格中,其中一列被分配了以下值
'value' => function ($data) {
$m = 'г';
$g = 'с';
$ps = 'пс';
$summ = 0;
$str = '';
$strt = '';
foreach($data->itemsOrder as $request) {
$summ = $request->order_items_quantity;
$str .= (strlen($str))?', ': '';
$externalId = $request->orderInfo->order_items_offer_externalId;
if($externalId == 'cream-009-1' or $externalId == 'cream-009-2'){
$strt = $m;
}
elseif($externalId == 'cream-002-1' or $externalId == 'cream-002-2'){
$strt = $g;
}
elseif($externalId == 'cream-005-1' or $externalId == 'cream-005-2'){
$strt = $ps;
}
else{
$strt = '';
}
if(strstr($strt, $ps)){
$str .= $summ.$strt;
}
elseif(strstr($strt, $g)){
$str .= $summ.$strt;
}
elseif(strstr($strt, $m)){
$str .= $summ.$strt;
}
else{
$str .= '';
}
}
return $str;
},
],
输出形式为6пс, 2пс, 6г, 2г, 1с
,如何将其转换为以下形式:8пс, 8г, 1с
?
更新。找到了解决方案
1 个回答