Page 1 of 1

Konvertieren Sie drei Spalten aus einem 2D-Array in ein assoziatives Array aus assoziativen Arrays

Posted: 29 Dec 2024, 10:01
by Anonymous
Ich habe ein Array, das diesem ähnelt:

Code: Select all

Array
(
[0] => Array
(
[cartId] => 51
[attributeId] => 171
[Value] => 34
[quantity] => 1
)

[1] => Array
(
[cartId] => 51
[attributeId] => 170
[Value] => Adult
[quantity] => 1
)

[2] => Array
(
[cartId] => 52
[attributeId] => 171
[Value] => 36
[quantity] => 1
)

[3] => Array
(
[cartId] => 52
[attributeId] => 170
[Value] => Adult
[quantity] => 1
)
)
Ich möchte es folgendermaßen neu anordnen:

Code: Select all

Array
(
[51] => Array
(
[171] => 34
[170] => Adult
)

[52] => Array
(
[171] => 36
[170] => Adult
)
)
Grundsätzlich möchte ich, dass die Warenkorb-ID der übergeordnete Schlüssel und die Attribut-ID der Unterschlüssel ist und der Wert der entsprechende Wert ist und alle Datensätze unter eine Warenkorb-ID fallen.