我有一個csv文件。我需要讀取和格式化數組才能導入。我的頭都這個樣子,用另一個數組鍵替換一個數組鍵php
Array
(
[0] => id
[1] => name
[2] => shortDescription
[3] => description
[4] => productType
[5] => sku
[6] => styleCode
)
我的值是這個樣子的,
Array
(
[0] => Array
(
[0] => 185
[1] => T-shirts
[2] => this is tshirt short desc
[3] => This is tshirt desc
[4] => simple
[5] => 4585
[6] => 5292++
)
[1] => Array
(
[0] => 186
[1] => test name
[2] => test short desc
[3] => test desc
[4] => configurable
[5] => 525
[6] => 555
)
)
在這裏,我需要更換相應的標頭值我值的每個關鍵。所以我的最終陣列應該是這樣的,
Array
(
[0] => Array
(
[id] => 185
[name => T-shirts
[shortdescription] => this is tshirt short desc
[description] => This is tshirt desc
[producttype] => simple
[sku] => 4585
[stylecode] => 5292++
)
[1] => Array
(
[id] => 186
[name] => test name
[shortdescription] => test short desc
[description] => test desc
[producttype] => configurable
[sku] => 525
[stylecode] => 555
)
)
我找不到這個好的解決方案。有人幫我解決這個問題嗎?
你有沒有嘗試過或做過一些研究? – Rizier123 2015-03-31 05:05:05
是的,我嘗試了一些東西,但它不工作,所以沒有在這裏發佈。 – Elavarasan 2015-03-31 05:06:03
瞭解'array_combine' – 2015-03-31 05:06:50