私は以下のような配列を持っています。 atrributesは、配列ごとにorder_id、qty、sell_price、product_nameおよびmerchant_nameです。私は、同じORDER_IDに基づいてマップと同じORDER_ID 1より大きいPHPを使用してカスタム配列をマッピングする方法は?
[items:protected] => Array
(
[0] => stdClass Object
(
[order_id] => 1
[qty] => 1
[sell_price] => 45000.00
[product_name] => Omni Bars Cokelat Kelapa
[merchant_name] => Health & Co.
)
[1] => stdClass Object
(
[order_id] => 1
[qty] => 1
[sell_price] => 55000.00
[product_name] => Trim Eats Strawberry Banana Cream Overnight Oats
[merchant_name] => Trim Eats
)
[2] => stdClass Object
(
[order_id] => 1
[qty] => 1
[sell_price] => 28000.00
[product_name] => Everything Banana Keripik Pisang Rumput Laut
[merchant_name] => EverythingBanana
)
[3] => stdClass Object
(
[order_id] => 2
[qty] => 1
[sell_price] => 35000.00
[product_name] => Naked Bar Banana Nutter
[merchant_name] => Naked Foodss
)
[4] => stdClass Object
(
[order_id] => 3
[qty] => 1
[sell_price] => 200000.00
[product_name] => Health & Co. Paket Detoks 1 Hari
[merchant_name] => Health & Co.
)
[5] => stdClass Object
(
[order_id] => 3
[qty] => 1
[sell_price] => 38000.00
[product_name] => Health & Co. Paket 3 Botol Holy Kale
[merchant_name] => Health & Co.
)
)
私はORDER_IDがある鍵を使用してこのような何かに配列をマッピングしたい場合は、アレイになる属性を変更したいです。
[1] => stdClass Object
(
[qty] => [1,1,1]
[sell_price] => [45000.00, 55000.00, 28000.00]
[product_name] => [Omni Bars Cokelat Kelapa, Trim Eats Strawberry Banana Cream Overnight Oats, Everything Banana Keripik Pisang Rumput Laut]
[merchant_name] => [Health & Co, Trim Eats, EverythingBanana]
)
[2] => so on....
私はそれを固執しました。私を助けてください。
あなたはすでにあなたが私たちと共有することができ書かれた任意のコードを持っていますか?これは簡単に解決できる質問のようです。 –
実際にこのように組み合わせる必要はありますか? 4つの配列に分割するのではなく、すべての製品の属性をまとめて保存する方がいいでしょう。 – xs0
はい、確かです。私はExcelでデータを生成したいので、このように結合する必要があります。 – Axaxaxaxax