У меня есть текущий массив в PHP, который извлекается из базы данных MySQL (PDO fetch all);
[0] => Array
(
[id] => 78
[indent] => 2.2
[partnumber] => OPPN-39-596
[description] => BACK WASH NOZZLE - 32 DIA
[size] =>
[rev] => A
[code] => MCH
[quantity] => 1
[total] => 1
[notes] =>
[partcost] =>
[totalcost] =>
)
[1] => Array
(
[id] => 23
[indent] => 2.3
[partnumber] => OPPN-21-508
[description] => FRONT 12MM JET ASSY
[size] =>
[rev] => A
[code] => ASY
[quantity] => 3
[total] => 3
[notes] =>
[partcost] =>
[totalcost] =>
)
[2] => Array
(
[id] => 17
[indent] => 2.3.1
[partnumber] => OPPN-21-356
[description] => INTERNAL CIRCLIP Ø42 BORE S/S
[size] =>
[rev] =>
[code] => HRD
[quantity] => 1
[total] => 3
[notes] =>
[partcost] =>
[totalcost] =>
)
[3] => Array
(
[id] => 26
[indent] => 2.3.2
[partnumber] => OPPN-21-509
[description] => FRONT JET 12MM NOZZLE
[size] =>
[rev] => A
[code] => MCH
[quantity] => 1
[total] => 3
[notes] =>
[partcost] =>
[totalcost] =>
)
[4] => Array
(
[id] => 28
[indent] => 2.3.3
[partnumber] => OPPN-21-510
[description] => FLOW STRAIGHTENER 12MM INSERT 1
[size] =>
[rev] => A
[code] => MCH
[quantity] => 1
[total] => 3
[notes] =>
[partcost] =>
[totalcost] =>
)
[5] => Array
(
[id] => 30
[indent] => 2.3.4
[partnumber] => OPPN-21-511
[description] => FLOW STRAIGHTENER 12MM INSERT 2
[size] =>
[rev] => A
[code] => MCH
[quantity] => 1
[total] => 3
[notes] =>
[partcost] =>
[totalcost] =>
)
[6] => Array
(
[id] => 34
[indent] => 2.3.5
[partnumber] => OPPN-21-524
[description] => O RING 3.53 X 32.92 ID NITRILE
[size] =>
[rev] => A
[code] => HRD
[quantity] => 1
[total] => 3
[notes] =>
[partcost] =>
[totalcost] =>
)
[7] => Array
(
[id] => 76
[indent] => 2.4
[partnumber] => OPPN-39-592
[description] => FRONT 14MM JET ASSY
[size] =>
[rev] => A
[code] => ASY
[quantity] => 10
[total] => 10
[notes] =>
[partcost] =>
[totalcost] =>
)
[8] => Array
(
[id] => 67
[indent] => 2.4.1
[partnumber] => OPPN-39-581
[description] => FRONT JET 14MM NOZZLE
[size] =>
[rev] => A
[code] => MCH
[quantity] => 1
[total] => 10
[notes] =>
[partcost] =>
[totalcost] =>
)
Мне нужно придумать код для преобразования массива в этот;
[0] => Array
(
[id] => 78
[indent] => 2.2
[partnumber] => OPPN-39-596
[description] => BACK WASH NOZZLE - 32 DIA
[size] =>
[rev] => A
[code] => MCH
[quantity] => 1
[total] => 1
[notes] =>
[partcost] =>
[totalcost] =>
)
[1] => Array
(
[id] => 23
[indent] => 2.3
[partnumber] => OPPN-21-508
[description] => FRONT 12MM JET ASSY
[size] =>
[rev] => A
[code] => ASY
[quantity] => 3
[total] => 3
[notes] =>
[partcost] =>
[totalcost] =>
[0] => Array
(
[id] => 17
[indent] => 2.3.1
[partnumber] => OPPN-21-356
[description] => INTERNAL CIRCLIP Ø42 BORE S/S
[size] =>
[rev] =>
[code] => HRD
[quantity] => 1
[total] => 3
[notes] =>
[partcost] =>
[totalcost] =>
)
[1] => Array
(
[id] => 26
[indent] => 2.3.2
[partnumber] => OPPN-21-509
[description] => FRONT JET 12MM NOZZLE
[size] =>
[rev] => A
[code] => MCH
[quantity] => 1
[total] => 3
[notes] =>
[partcost] =>
[totalcost] =>
)
[2] => Array
(
[id] => 28
[indent] => 2.3.3
[partnumber] => OPPN-21-510
[description] => FLOW STRAIGHTENER 12MM INSERT 1
[size] =>
[rev] => A
[code] => MCH
[quantity] => 1
[total] => 3
[notes] =>
[partcost] =>
[totalcost] =>
)
[3] => Array
(
[id] => 30
[indent] => 2.3.4
[partnumber] => OPPN-21-511
[description] => FLOW STRAIGHTENER 12MM INSERT 2
[size] =>
[rev] => A
[code] => MCH
[quantity] => 1
[total] => 3
[notes] =>
[partcost] =>
[totalcost] =>
)
[4] => Array
(
[id] => 34
[indent] => 2.3.5
[partnumber] => OPPN-21-524
[description] => O RING 3.53 X 32.92 ID NITRILE
[size] =>
[rev] => A
[code] => HRD
[quantity] => 1
[total] => 3
[notes] =>
[partcost] =>
[totalcost] =>
)
)
[2] => Array
(
[id] => 76
[indent] => 2.4
[partnumber] => OPPN-39-592
[description] => FRONT 14MM JET ASSY
[size] =>
[rev] => A
[code] => ASY
[quantity] => 10
[total] => 10
[notes] =>
[partcost] =>
[totalcost] =>
[0] => Array
(
[id] => 67
[indent] => 2.4.1
[partnumber] => OPPN-39-581
[description] => FRONT JET 14MM NOZZLE
[size] =>
[rev] => A
[code] => MCH
[quantity] => 1
[total] => 10
[notes] =>
[partcost] =>
[totalcost] =>
)
)
[3] => Array
(
[id] => 76
[indent] => 2.5
[partnumber] => OPPN-39-592
[description] => FRONT 14MM JET ASSY
[size] =>
[rev] => A
[code] => ASY
[quantity] => 10
[total] => 10
[notes] =>
[partcost] =>
[totalcost] =>
)
Элемент массива с отступом 2.3.1 становится дочерним элементом элемента с отступом 2.3 и т. Д. Мне нужно придумать код, который автоматически форматирует этот массив так, как мне нужно , Я целый день боролся с многомерными петлями, но мне не повезло. Любое руководство и помощь будут оценены.