我有这个数组:
array(122) {
["1AB168820010"]=> array(3) {
["MACHINE_NAME"]=> "L1XP2A"
["FEEDER_SLOT"]=> "114"
["REJECT_RATE"]=> float(0.0394)
["DEFECT_QTY"]=> int(2)
["SOLDER BALL"]=> int(2)
}
["1AB037870031"]=> array(5) {
["MACHINE_NAME"]=> "L2CP7A"
["FEEDER_SLOT"]=> "155"
["REJECT_RATE"]=> float(2.3022)
["DEFECT_QTY"]=> int(39)
["COMPONENT TOMBSTONED"]=> int(31)
["SOLDER BALL"]=> int(2)
["COMPONENT BILLBOARD"]=> int(6)
}
["1AB144890021"]=> array(7) {
["MACHINE_NAME"]=> "L21P3A"
["FEEDER_SLOT"]=> "214"
["REJECT_RATE"]=> float(0.0225)
["DEFECT_QTY"]=> int(8)
["SOLDER INSUFFICIENT "]=> int(2)
["SOLDER BAD"]=> int(2)
["SOLDER BALL"]=> int(2)
["COMPONENT MISSING"]=> int(1)
["COMPONENT BILLBOARD"]=> int(1)
}
["1AB144890033"]=> array(7) {
["MACHINE_NAME"]=> "L1CP7A"
["FEEDER_SLOT"]=> "234"
["REJECT_RATE"]=> float(0.0142)
["DEFECT_QTY"]=> int(7)
["SOLDER INSUFFICIENT "]=> int(1)
["SOLDER BAD"]=> int(1)
["COMPONENT MISSING"]=> int(3)
["COMPONENT SKEW"]=> int(1)
["COMPONENT TOMBSTONED"]=> int(1)
}
#...more
}
我需要遍历数组并从数组输出中创建一个字符串,看起来像这样但不知道最好的方法......请帮助
1AB168820010 ( 0.0394% ) #<-this is the 'REJECT_RATE'
-Machine: L1XP2A
-Feeder: 114
SOLDER BALL ( 100% ) #<-'SOLDER BALL' value (2) divided by 'DEFECT_QTY' (2) * 100
------------------------
1AB037870031 ( 2.3022% )
-Machine: L2CP7A
-Feeder: 155
COMPONENT TOMBSTONED ( 79.48% ) #<- ( 31 / 39 ) * 100
COMPONENT BILLBOARD ( 15.38% ) #<- ( 6 / 39 ) * 100
SOLDER BALL ( 5.12% ) #<- ( 2 / 39 ) * 100
------------------------
1AB144890021 ( 0.0225% )
-Machine: L2IP3A
-Feeder: 214
SOLDER INSUFFICIENT ( 25% )
SOLDER BAD ( 25% )
SOLDER BALL ( 25% )
COMPONENT MISSING ( 12.5% )
COMPONENT BILLBOARD ( 12.5% )
------------------------
1AB144890033 ( 0.0142% )
-Machine: L1CP7A
-Feeder: 234
SOLDER INSUFFICIENT ( 14.3% )
SOLDER BAD ( 14.3% )
COMPONENT MISSING ( 42.8% )
COMPONENT SKEWED ( 14.3% )
COMPONENT TOMBSTONED ( 14.3% )
我不知道如何处理的主要问题是我不知道每个零件编号的缺陷数量(即组件缺失、组件偏斜、焊料不良),有多少缺陷(以及它有哪些缺陷)会有所不同,因此我不能只是将“组件丢失:[一些计算]”硬编码到我的 foreach 循环中......