Array-Neuordnung in PHP
Posted: 29 Dec 2024, 07:11
Ich habe ein Array, das diesem ähnelt:
Ich möchte es folgendermaßen neu anordnen:
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.< /p>
Vielen Dank im Voraus.
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
)
)
Code: Select all
Array
(
[51] => Array
(
[171] => 34
[170] => Adult
)
[52] => Array
(
[171] => 36
[170] => Adult
)
)
Vielen Dank im Voraus.