Ich habe folgenden Array erstellt. Aber das ist nicht was ich eigentlich will. helfen, ein neues Array daraus zu erstellen, um meine Anforderungen zu erfüllen.Erstellen eines Arrays aus multiplen mehrdimensionalen Array in PHP
Array (
[supplier_id] => 1
[filter_name] => Array
(
[0] => product 1
[1] => Product 2
[2] => Product 3
)
[quantity] => Array
(
[0] => 3
[1] => 10
[2] => 2
)
[unit] => Array
(
[0] => pkts
[1] => ltrs
[2] => pkts
)
[price] => Array
(
[0] => 11
[1] => 100
[2] => 10
)
[gross_amount] => Array
(
[0] => 33
[1] => 1000
[2] => 20
)
[vat] => Array
(
[0] => 0
[1] => 0
[2] => 0
)
[net_amount] => Array
(
[0] => 33
[1] => 1000
[2] => 20
))
Und das ist das Array, das ich genau will. Gibt es eine Idee, diese Art von Array zu erstellen.
Array(
[supplier_id] = 1
[0] = Array(
[filter_name] => product 1
[quantity] => 3
[unit] => pkts
[price] => 11
[gross_amount] => 33
[vat] => 0
[net_amount] => 33
)
[1] = Array(
[filter_name] => product 2
[quantity] => 10
[unit] => ltrs
[price] => 100
[gross_amount] => 1000
[vat] => 0
[net_amount] => 1000
)
[2] = Array(
[filter_name] => product 3
[quantity] => 2
[unit] => pkts
[price] => 10
[gross_amount] => 20
[vat] => 0
[net_amount] => 20
))
Idea - 'verwenden foreach' –
Was hast du versucht? – Akintunde007
Können Sie Ihr Skript posten, um zu verstehen, woher die Daten stammen und wie Sie versucht haben, sie zu transformieren? Wie @u_mulder sagte, könnte ein 'foreach' ein guter Anfang sein. – vchabot