How can this one-dimensional array be transformed into a two-dimensional array based on the correlation of key names? Thank you
Thank you, brother! My one-dimensional array is as follows
PHP Code
? Array ([xm1] = artificial new bricklaying pipe well [dj1] [SL1] = [ZJ1] = 30000 [xm2] = bathroom Backfill [DJ2] [SL2] => ; [Zj2] = [XM3] + TV background wall [dj3] [SL3] = [ZJ3] + [XM4] + living room wine cabinet TV background wine cabinet [dj4] = [SL4] = [ ZJ4] = [XM5] = Door Shoe Cabinet Decoration (event delivery shoe cabinet) [dj5] = [SL5] = [Zj5] = [XM6] = Bookcase partition (with mute cotton interlayer) [dj6] = [SL 6] = [ZJ6] = [XM8] = kitchen mobile door Head storage cabinet [DJ8] [zj8] [SL8] = = [+] = [XM9] = children's room wardrobe partition (with mute cotton interlayer) [dj9] = [SL9] = [Zj9] = [XM10] = kitchen cabinet [dj10] = [SL10] = [ZJ10] = [XM11] = toilet wash-basin [DJ11] = [Sl11] = [ZJ11] = [XM12] = living room, dining room, aisle, gypsum board modelling ceiling [DJ12] [sl12] = [ZJ12] = [XM13] = toilet, kitchen Room integrated ceiling [DJ13] = [SL13] = [Zj13] = [XM14] = top, wall double fly powder latex paint [dj14] = [SL14] = [ZJ14] = [XM15] = = kitchen, laundry room, bathroom anti-skid floor tile [dj15] [sl15] = [Zj15] [xm16] = kitchen, bathroom wall mount 300*450 wall tile [dj16] = [SL16] = = [Zj16] + [xM17] = sill stone laying [dj17] = [SL17] = [zj17] = [XM18] = sill stone [dj18] = [SL18] = [Zj18] = [x M19] + anti-theft window [dj19] = [sl19] = [zj19] = [XM20] + book Door cover [Dj20] = [SL20] = [ZJ20] = [xm2 1] = toilet laundry door cover [dj21] [sl21] = [ZJ21] = [XM22] =, wall waterproof, moisture treatment [dj22] [sl22] = [ZJ22] = > [XM23] = water, circuit retrofit [dj23] = [sl23] = [zj23] = [Xm24] = finished cleaning service [dj24] [sl24] = Zj2 4] = [XM25] + finished protection fee [DJ25] = [SL25] = [ZJ25] = [XM26] = Material handling fee [DJ26] = 5 [Sl26] = [zj2 6] = [XM27] + garbage removal fee [DJ27] = 5 [sl27] = [zj27] = [XM28] = kitchen tiles (70 percent discount for activities) [dj28] = [SL28] =&G T [Zj28] [xm29] = kitchen wall tile (70 percent discount) [dj29] [sl29] = [zj29] = [XM30] = Bathroom Tiles (70 percent discount) [Dj30] = [Sl30] = [Zj30] = [XM31] + bathroom wall tile (event 70 percent discount) [dj31] = [sl31] = [zj31] = [Xm32] + Laminate flooring (event buy one send a) [dj32] = 170 [SL32] = [zj32] = [XM33] + bedroom suite door [dj33] = 730 [sl33] = [zj33] = [xm34] = bathroom door [dj34] + 570 [SL34] = [zj34] = [XM35] = kitchen mobile Door [dj35] [sl35] = [Zj35] = [XM36] + [dj36] = wardrobe Mobile Door 0 [sl36] [zj36] = [XM37] = kitchen, bathroom set ceiling [dj37] = 260 [sl37] = [zj37] = [XM38] = sill stone, cupboard counter face stone [dj38 ] = 260 [sl38] = [zj38] = [XM39] = sill stone [dj39] = [sl39] = [zj39] = =)
I would like to convert it into the following
PHP Code
Array ([0]=>array] ([XM] = artificial new bricklaying pipe well [DJ] [SL] = [ZJ] + 30000[1]=>array (...))
------Solution--------------------
PHP Code
$res = Array (), foreach ($arr as $k = = $v) { $res [substr ($k, 2) -1][substr ($k, 0, 2)] = $v;} /*array ( [0] = = Array ( [XM] = artificial new bricklaying pipe Well [DJ] [ SL] = [ ZJ] = 30000< c13/>) [1] = = Array ( [XM] = bathroom Backfill [DJ] [SL] = [ ZJ] = = ) */