array(
"536-01033L" => array (
0 => array ("id" => "BB8", "company" => "CS (BB8)", "part" => "CALIPER", "age" => "543", "cond" => "A", "stock" => "ZZ0759", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "1E44", "comments" => "LH,SE"),
1 => array ("id" => "BB8", "company" => "CS (BB8)", "part" => "CALIPER", "age" => "459", "cond" => "A", "stock" => "170032", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "1I29", "comments" => "LH,SXT,ABS"),
2 => array ("id" => "BB8", "company" => "CS (BB8)", "part" => "CALIPER", "age" => "431", "cond" => "B", "stock" => "170060", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "1I20", "comments" => "LH,ABS"),
3 => array ("id" => "BB8", "company" => "CS (BB8)", "part" => "CALIPER", "age" => "388", "cond" => "A", "stock" => "170101", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "1K08", "comments" => "LH"),
4 => array ("id" => "BB8", "company" => "CS (BB8)", "part" => "CALIPER", "age" => "372", "cond" => "A", "stock" => "170130", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "1N05", "comments" => "LH,ABS"),
5 => array ("id" => "BB8", "company" => "CS (BB8)", "part" => "CALIPER", "age" => "270", "cond" => "A", "stock" => "170189", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "1D26", "comments" => "LH"),
6 => array ("id" => "BB8", "company" => "CS (BB8)", "part" => "CALIPER", "age" => "210", "cond" => "A", "stock" => "170211", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "1T01", "comments" => "LH,SE,ABS"),
7 => array ("id" => "BB8", "company" => "CS (BB8)", "part" => "CALIPER", "age" => "63", "cond" => "A", "stock" => "180306", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "1B19", "comments" => "LH,REAR, L."),
8 => array ("id" => "BB8", "company" => "CS (BB8)", "part" => "CALIPER", "age" => "38", "cond" => "A", "stock" => "S06738", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "1C36", "comments" => "LH,ABS,REAR, L."),
9 => array ("id" => "KY1", "company" => "BAP (KY1)", "part" => "CALIPER", "age" => "35", "cond" => "A", "stock" => "F0050628", "ic" => "536-01033L", "holl" => "536", "price" => "10.00", "qty" => "1", "location" => "TRU044", "comments" => ""),
10 => array ("id" => "KY1", "company" => "BAP (KY1)", "part" => "CALIPER", "age" => "31", "cond" => "A", "stock" => "F0050688", "ic" => "536-01033L", "holl" => "536", "price" => "10.00", "qty" => "1", "location" => "TRU057", "comments" => ""),
11 => array ("id" => "KY1", "company" => "BAP (KY1)", "part" => "CALIPER", "age" => "11", "cond" => "A", "stock" => "F0051105", "ic" => "536-01033L", "holl" => "536", "price" => "10.00", "qty" => "1", "location" => "TRU044", "comments" => ""),
12 => array ("id" => "KY2", "company" => "BGAP (KY2)", "part" => "CALIPER", "age" => "667", "cond" => "A", "stock" => "B6H112", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "Y02I05", "comments" => ""),
13 => array ("id" => "KY2", "company" => "BGAP (KY2)", "part" => "CALIPER", "age" => "576", "cond" => "A", "stock" => "B6K193", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "Y02L06", "comments" => ""),
14 => array ("id" => "KY2", "company" => "BGAP (KY2)", "part" => "CALIPER", "age" => "528", "cond" => "A", "stock" => "B6L236", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "Y02P04", "comments" => ""),
15 => array ("id" => "KY2", "company" => "BGAP (KY2)", "part" => "CALIPER", "age" => "403", "cond" => "A", "stock" => "B7E079", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "Y02R12", "comments" => ""),
16 => array ("id" => "KY2", "company" => "BGAP (KY2)", "part" => "CALIPER", "age" => "340", "cond" => "A", "stock" => "B7E099", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "Y01T07", "comments" => ""),
17 => array ("id" => "KY2", "company" => "BGAP (KY2)", "part" => "CALIPER", "age" => "269", "cond" => "A", "stock" => "B7G138", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "Y02C01", "comments" => ""),
18 => array ("id" => "KY2", "company" => "BGAP (KY2)", "part" => "CALIPER", "age" => "239", "cond" => "A", "stock" => "B7J204", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "Y03D11", "comments" => ""),
19 => array ("id" => "KY2", "company" => "BGAP (KY2)", "part" => "CALIPER", "age" => "190", "cond" => "A", "stock" => "B7K232", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "MCICOR1", "comments" => ""),
20 => array ("id" => "MD6", "company" => "BWAP (MD6)", "part" => "CALIPER", "age" => "2", "cond" => "A", "stock" => "8A415", "ic" => "536-01033L", "holl" => "536", "price" => "12.00", "qty" => "1", "location" => "LOT-23", "comments" => ""),
21 => array ("id" => "M06", "company" => "MAP (M06)", "part" => "CALIPER", "age" => "162", "cond" => "A", "stock" => "1710131", "ic" => "536-01033L", "holl" => "536", "price" => "50.00", "qty" => "1", "location" => "KCA-10", "comments" => "128K"),
22 => array ("id" => "M06", "company" => "MAP (M06)", "part" => "CALIPER", "age" => "137", "cond" => "A", "stock" => "1800459", "ic" => "536-01033L", "holl" => "536", "price" => "50.00", "qty" => "1", "location" => "KCD-07", "comments" => "115K"),
23 => array ("id" => "M06", "company" => "MAP (M06)", "part" => "CALIPER", "age" => "46", "cond" => "A", "stock" => "1802696", "ic" => "536-01033L", "holl" => "536", "price" => "50.00", "qty" => "1", "location" => "KCE-14", "comments" => "144K"),
24 => array ("id" => "M06", "company" => "MAP (M06)", "part" => "CALIPER", "age" => "10", "cond" => "A", "stock" => "1803621", "ic" => "536-01033L", "holl" => "536", "price" => "50.00", "qty" => "1", "location" => "KCDM-A-09", "comments" => "130K"),
25 => array ("id" => "M06", "company" => "MAP (M06)", "part" => "CALIPER", "age" => "4", "cond" => "A", "stock" => "1803780", "ic" => "536-01033L", "holl" => "536", "price" => "50.00", "qty" => "1", "location" => "KCDM-A-20", "comments" => "136K"),
26 => array ("id" => "NC1", "company" => "APS (NC1)", "part" => "CALIPER", "age" => "135", "cond" => "A", "stock" => "DD1143", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "Y14B45", "comments" => "IN CAR 8EXC"),
27 => array ("id" => "TN9", "company" => "MSAP (TN9)", "part" => "CALIPER", "age" => "150", "cond" => "A", "stock" => "24092", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "13C33", "comments" => "ABS,LR"),
28 => array ("id" => "VA2", "company" => "CBAP (VA2)", "part" => "CALIPER", "age" => "371", "cond" => "A", "stock" => "CPC1187", "ic" => "536-01033L", "holl" => "536", "price" => "25.00", "qty" => "1", "location" => "BIN360A52", "comments" => ""),
29 => array ("id" => "VA2", "company" => "CBAP (VA2)", "part" => "CALIPER", "age" => "332", "cond" => "A", "stock" => "CPA1590", "ic" => "536-01033L", "holl" => "536", "price" => "25.00", "qty" => "1", "location" => "32.BJC.3", "comments" => ""),
30 => array ("id" => "VA2", "company" => "CBAP (VA2)", "part" => "CALIPER", "age" => "585", "cond" => "A", "stock" => "CNT2318", "ic" => "536-01033L", "holl" => "536", "price" => "15.00", "qty" => "1", "location" => "BIN360A48", "comments" => ""),
31 => array ("id" => "VA2", "company" => "CBAP (VA2)", "part" => "CALIPER", "age" => "452", "cond" => "A", "stock" => "CPC542", "ic" => "536-01033L", "holl" => "536", "price" => "12.00", "qty" => "1", "location" => "BIN360A34", "comments" => ""),
32 => array ("id" => "VA2", "company" => "CBAP (VA2)", "part" => "CALIPER", "age" => "444", "cond" => "A", "stock" => "CPA624", "ic" => "536-01033L", "holl" => "536", "price" => "12.00", "qty" => "1", "location" => "BIN360A32", "comments" => ""),
33 => array ("id" => "VA2", "company" => "CBAP (VA2)", "part" => "CALIPER", "age" => "541", "cond" => "A", "stock" => "CNC2667", "ic" => "536-01033L", "holl" => "536", "price" => "10.00", "qty" => "1", "location" => "BIN360A34", "comments" => ""),
34 => array ("id" => "VA2", "company" => "CBAP (VA2)", "part" => "CALIPER", "age" => "540", "cond" => "A", "stock" => "CNC2586", "ic" => "536-01033L", "holl" => "536", "price" => "10.00", "qty" => "1", "location" => "BIN360A17", "comments" => ""),
35 => array ("id" => "VA1", "company" => "AFUAP (VA1)", "part" => "CALIPER", "age" => "92", "cond" => "A", "stock" => "388078", "ic" => "536-01033L", "holl" => "536", "price" => "55.00", "qty" => "1", "location" => "W03D109", "comments" => ""),
36 => array ("id" => "VA1", "company" => "AFUAP (VA1)", "part" => "CALIPER", "age" => "91", "cond" => "A", "stock" => "388395", "ic" => "536-01033L", "holl" => "536", "price" => "55.00", "qty" => "1", "location" => "W03D98", "comments" => ""),
37 => array ("id" => "VA8", "company" => "GAS (VA8)", "part" => "CALIPER", "age" => "22", "cond" => "A", "stock" => "8E6669", "ic" => "536-01033L", "holl" => "536", "price" => "10.00", "qty" => "1", "location" => "TRUE CORE", "comments" => ""),
38 => array ("id" => "WV3", "company" => "APO (WV3)", "part" => "CALIPER", "age" => "325", "cond" => "A", "stock" => "G7G234", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "Z05B35", "comments" => ""),
),
"536-01036" => array (
0 => array ("id" => "M21", "company" => "BWUPI (M21)", "part" => "CALIPER", "age" => "122", "cond" => "A", "stock" => "8A065", "ic" => "536-01036", "holl" => "536", "price" => "15.00", "qty" => "1", "location" => "36AU", "comments" => ""),
1 => array ("id" => "M22", "company" => "BWSS (M22)", "part" => "CALIPER", "age" => "122", "cond" => "A", "stock" => "8A065", "ic" => "536-01036", "holl" => "536", "price" => "15.00", "qty" => "1", "location" => "36AU", "comments" => ""),
2 => array ("id" => "M23", "company" => "BWA (M23)", "part" => "CALIPER", "age" => "122", "cond" => "A", "stock" => "8A065", "ic" => "536-01036", "holl" => "536", "price" => "15.00", "qty" => "1", "location" => "36AU", "comments" => ""),
3 => array ("id" => "VA2", "company" => "CBAP (VA2)", "part" => "CALIPER", "age" => "357", "cond" => "A", "stock" => "CPA1257", "ic" => "536-01036", "holl" => "536", "price" => "12.00", "qty" => "1", "location" => "BIN.360.A", "comments" => ""),
),
"536-01037" => array (
0 => array ("id" => "KY1", "company" => "BAP (KY1)", "part" => "CALIPER", "age" => "16", "cond" => "A", "stock" => "F0050893", "ic" => "536-01037", "holl" => "536", "price" => "15.00", "qty" => "1", "location" => "HX0208", "comments" => ""),
1 => array ("id" => "VA2", "company" => "CBAP (VA2)", "part" => "CALIPER", "age" => "417", "cond" => "A", "stock" => "CPA779", "ic" => "536-01037", "holl" => "536", "price" => "12.00", "qty" => "1", "location" => "BIN360A42", "comments" => ""),
),
)
What I want to do is take the FIRST 2 entries from each id and put it into another array with same structure. If there is nly one entry, then it should be that one.array(
"536-01033L" => array (
0 => array ("id" => "BB8", "company" => "CS (BB8)", "part" => "CALIPER", "age" => "543", "cond" => "A", "stock" => "ZZ0759", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "1E44", "comments" => "LH,SE"),
1 => array ("id" => "BB8", "company" => "CS (BB8)", "part" => "CALIPER", "age" => "459", "cond" => "A", "stock" => "170032", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "1I29", "comments" => "LH,SXT,ABS"),
2 => array ("id" => "KY1", "company" => "BAP (KY1)", "part" => "CALIPER", "age" => "35", "cond" => "A", "stock" => "F0050628", "ic" => "536-01033L", "holl" => "536", "price" => "10.00", "qty" => "1", "location" => "TRU044", "comments" => ""),
3 => array ("id" => "KY1", "company" => "BAP (KY1)", "part" => "CALIPER", "age" => "31", "cond" => "A", "stock" => "F0050688", "ic" => "536-01033L", "holl" => "536", "price" => "10.00", "qty" => "1", "location" => "TRU057", "comments" => ""),
4 => array ("id" => "KY2", "company" => "BGAP (KY2)", "part" => "CALIPER", "age" => "667", "cond" => "A", "stock" => "B6H112", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "Y02I05", "comments" => ""),
5 => array ("id" => "KY2", "company" => "BGAP (KY2)", "part" => "CALIPER", "age" => "576", "cond" => "A", "stock" => "B6K193", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "Y02L06", "comments" => ""),
6 => array ("id" => "MD6", "company" => "BWAP (MD6)", "part" => "CALIPER", "age" => "2", "cond" => "A", "stock" => "8A415", "ic" => "536-01033L", "holl" => "536", "price" => "12.00", "qty" => "1", "location" => "LOT-23", "comments" => ""),
7 => array ("id" => "M06", "company" => "MAP (M06)", "part" => "CALIPER", "age" => "162", "cond" => "A", "stock" => "1710131", "ic" => "536-01033L", "holl" => "536", "price" => "50.00", "qty" => "1", "location" => "KCA-10", "comments" => "128K"),
8 => array ("id" => "NC1", "company" => "APS (NC1)", "part" => "CALIPER", "age" => "135", "cond" => "A", "stock" => "DD1143", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "Y14B45", "comments" => "IN CAR 8EXC"),
9 => array ("id" => "TN9", "company" => "MSAP (TN9)", "part" => "CALIPER", "age" => "150", "cond" => "A", "stock" => "24092", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "13C33", "comments" => "ABS,LR"),
10 => array ("id" => "VA2", "company" => "CBAP (VA2)", "part" => "CALIPER", "age" => "371", "cond" => "A", "stock" => "CPC1187", "ic" => "536-01033L", "holl" => "536", "price" => "25.00", "qty" => "1", "location" => "BIN360A52", "comments" => ""),
11 => array ("id" => "VA2", "company" => "CBAP (VA2)", "part" => "CALIPER", "age" => "332", "cond" => "A", "stock" => "CPA1590", "ic" => "536-01033L", "holl" => "536", "price" => "25.00", "qty" => "1", "location" => "32.BJC.3", "comments" => ""),
12 => array ("id" => "VA1", "company" => "AFUAP (VA1)", "part" => "CALIPER", "age" => "92", "cond" => "A", "stock" => "388078", "ic" => "536-01033L", "holl" => "536", "price" => "55.00", "qty" => "1", "location" => "W03D109", "comments" => ""),
13 => array ("id" => "VA1", "company" => "AFUAP (VA1)", "part" => "CALIPER", "age" => "91", "cond" => "A", "stock" => "388395", "ic" => "536-01033L", "holl" => "536", "price" => "55.00", "qty" => "1", "location" => "W03D98", "comments" => ""),
14 => array ("id" => "VA8", "company" => "GAS (VA8)", "part" => "CALIPER", "age" => "22", "cond" => "A", "stock" => "8E6669", "ic" => "536-01033L", "holl" => "536", "price" => "10.00", "qty" => "1", "location" => "TRUE CORE", "comments" => ""),
15 => array ("id" => "WV3", "company" => "APO (WV3)", "part" => "CALIPER", "age" => "325", "cond" => "A", "stock" => "G7G234", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "Z05B35", "comments" => ""),
),
"536-01036" => array (
0 => array ("id" => "M21", "company" => "BWUPI (M21)", "part" => "CALIPER", "age" => "122", "cond" => "A", "stock" => "8A065", "ic" => "536-01036", "holl" => "536", "price" => "15.00", "qty" => "1", "location" => "36AU", "comments" => ""),
1 => array ("id" => "M22", "company" => "BWSS (M22)", "part" => "CALIPER", "age" => "122", "cond" => "A", "stock" => "8A065", "ic" => "536-01036", "holl" => "536", "price" => "15.00", "qty" => "1", "location" => "36AU", "comments" => ""),
2 => array ("id" => "M23", "company" => "BWA (M23)", "part" => "CALIPER", "age" => "122", "cond" => "A", "stock" => "8A065", "ic" => "536-01036", "holl" => "536", "price" => "15.00", "qty" => "1", "location" => "36AU", "comments" => ""),
3 => array ("id" => "VA2", "company" => "CBAP (VA2)", "part" => "CALIPER", "age" => "357", "cond" => "A", "stock" => "CPA1257", "ic" => "536-01036", "holl" => "536", "price" => "12.00", "qty" => "1", "location" => "BIN.360.A", "comments" => ""),
),
"536-01037" => array (
0 => array ("id" => "KY1", "company" => "BAP (KY1)", "part" => "CALIPER", "age" => "16", "cond" => "A", "stock" => "F0050893", "ic" => "536-01037", "holl" => "536", "price" => "15.00", "qty" => "1", "location" => "HX0208", "comments" => ""),
1 => array ("id" => "VA2", "company" => "CBAP (VA2)", "part" => "CALIPER", "age" => "417", "cond" => "A", "stock" => "CPA779", "ic" => "536-01037", "holl" => "536", "price" => "12.00", "qty" => "1", "location" => "BIN360A42", "comments" => ""),
),
)
ASKER
array(
"536-01033L" => array (
0 => array ("id" => "BB8", "company" => "CS (BB8)", "part" => "CALIPER", "age" => "543", "cond" => "A", "stock" => "ZZ0759", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "1E44", "comments" => "LH,SE"),
1 => array ("id" => "BB8", "company" => "CS (BB8)", "part" => "CALIPER", "age" => "459", "cond" => "A", "stock" => "170032", "ic" => "536-01033L", "holl" => "536", "price" => "35.00", "qty" => "1", "location" => "1I29", "comments" => "LH,SXT,ABS"),
),
"536-01036" => array (
0 => array ("id" => "M21", "company" => "BWUPI (M21)", "part" => "CALIPER", "age" => "122", "cond" => "A", "stock" => "8A065", "ic" => "536-01036", "holl" => "536", "price" => "15.00", "qty" => "1", "location" => "36AU", "comments" => ""),
1 => array ("id" => "M22", "company" => "BWSS (M22)", "part" => "CALIPER", "age" => "122", "cond" => "A", "stock" => "8A065", "ic" => "536-01036", "holl" => "536", "price" => "15.00", "qty" => "1", "location" => "36AU", "comments" => ""),
),
"536-01037" => array (
0 => array ("id" => "KY1", "company" => "BAP (KY1)", "part" => "CALIPER", "age" => "16", "cond" => "A", "stock" => "F0050893", "ic" => "536-01037", "holl" => "536", "price" => "15.00", "qty" => "1", "location" => "HX0208", "comments" => ""),
1 => array ("id" => "VA2", "company" => "CBAP (VA2)", "part" => "CALIPER", "age" => "417", "cond" => "A", "stock" => "CPA779", "ic" => "536-01037", "holl" => "536", "price" => "12.00", "qty" => "1", "location" => "BIN360A42", "comments" => ""),
),
)
ASKER
ASKER
ASKER
$new_arr = array();
foreach($x as $k=>$v) {
$id = "";
$cnt = 1;
$new_arr[$k] = array();
foreach($v as $ic) {
if($id !== $ic["id"] and $cnt < 3) {
if(is_array($ic)) {
array_push($new_arr[$k], $ic);
}
$id = $ic["id"];
$cnt++;
}
};
};
print_r($new_arr);
ASKER
PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.
TRUSTED BY