php - 如何过滤二维数组并将重复数获取到唯一行数中
问题描述
我有一个问题,我必须计算数组中的缺陷数量,并且还要删除与名称和问题有关的任何重复,而不是原因。
我尝试使用循环删除重复值,但我不知道如何使用重复次数更新 Qty 列。
我想用唯一值过滤下面的数组,并计算数组中的重复次数并将其作为 Qty 输入到第一行。
I need the output like
SlNo name Problem Qty
1. Tata brake 3
2. xeq fuel 2
3. Shift headlight 1
Can anyone help me out with this issue... Thanks
<?PHP
$AryCars = array(
0 => array(
'name' => 'Tata',
'Problem' => 'brake',
'Cause' => 'drum'
'Qty' => '1'
),
1 => array(
'name' => 'xeq',
'Problem' => 'fuel',
'Cause' => 'pump failure'
'Qty' => '1'
),
2 => array(
'name' => 'xeq',
'Problem' => 'fuel',
'Cause' => 'tank damage'
'Qty' => '1'
),
2 => array(
'name' => 'Tata',
'Problem' => 'brake',
'Cause' => 'oil leak'
'Qty' => '1'
),
3 => array(
'name' => 'xeq',
'Problem' => 'fuel',
'Cause' => 'fuel'
'Qty' => '1'
),
4 => array(
'name' => 'Tata',
'Problem' => 'brake',
'Cause' => 'damage'
'Qty' => '1'
),
5 => array(
'name' => 'Shift',
'Problem' => 'headlight',
'Cause' => 'fuse'
'Qty' => '1'
)
)
?>