誰かがここで私を助けてくれることを願っています。
次の配列を想像してください。
Array
(
[blue__##__m__##__10] => 13
[blue__##__m__##__20] => 13
[blue__##__m__##__30] => 13
[blue__##__xl__##__10] => 18
[blue__##__xl__##__20] => 18
[blue__##__xl__##__30] => 18
[blue__##__xs__##__10] => 12
[blue__##__xs__##__20] => 12
[blue__##__xs__##__30] => 12
[green__##__m__##__10] => 17
[green__##__m__##__20] => 17
[green__##__m__##__30] => 17
[green__##__xl__##__10] => 15
[green__##__xl__##__20] => 15
[green__##__xl__##__30] => 15
[green__##__xs__##__10] => 11
[green__##__xs__##__20] => 11
[green__##__xs__##__30] => 11
[red__##__m__##__10] => 16
[red__##__m__##__20] => 16
[red__##__m__##__30] => 16
[red__##__xl__##__10] => 10
[red__##__xl__##__20] => 10
[red__##__xl__##__30] => 10
[red__##__xs__##__10] => 21
[red__##__xs__##__20] => 21
[red__##__xs__##__30] => 21
)
最も一般的な属性 ( ##は implode からのものです* 残りは属性です)でそれを整理し、あまり一般的でないものを削除したいと思います。
結果は次のようになります。
Array
(
[blue] => array[13,18,12]
[green] => array[17,15,11]
[red] => array[16,10,21]
)
機能させるには、除外された属性を提供するようにユーザーに依頼する必要がありますか? 例: [xs,xl,xs,10,20,30] を除外するか、属性グループ [attribute_pa_size,attribute_height] で除外します (元の内破を参照)
*内破前の元の配列:
Array
(
[0] => Array
(
[pid] => 100
[variations] => Array
(
[0] => Array
(
[attributes] => Array
(
[attribute_pa_color] => blue
[attribute_pa_size] => m
[attribute_height] => 10
)
[image_id] => 13
)
[1] => Array
(
[attributes] => Array
(
[attribute_pa_color] => blue
[attribute_pa_size] => m
[attribute_height] => 20
)
[image_id] => 13
)
[2] => Array
(
[attributes] => Array
(
[attribute_pa_color] => blue
[attribute_pa_size] => m
[attribute_height] => 30
)
[image_id] => 13
)
[3] => Array
(
[attributes] => Array
(
[attribute_pa_color] => blue
[attribute_pa_size] => xl
[attribute_height] => 10
)
[image_id] => 18
)
[4] => Array
(
[attributes] => Array
(
[attribute_pa_color] => blue
[attribute_pa_size] => xl
[attribute_height] => 20
)
[image_id] => 18
)
[5] => Array
(
[attributes] => Array
(
[attribute_pa_color] => blue
[attribute_pa_size] => xl
[attribute_height] => 30
)
[image_id] => 18
)
[6] => Array
(
[attributes] => Array
(
[attribute_pa_color] => blue
[attribute_pa_size] => xs
[attribute_height] => 10
)
[image_id] => 12
)
[7] => Array
(
[attributes] => Array
(
[attribute_pa_color] => blue
[attribute_pa_size] => xs
[attribute_height] => 20
)
[image_id] => 12
)
[8] => Array
(
[attributes] => Array
(
[attribute_pa_color] => blue
[attribute_pa_size] => xs
[attribute_height] => 30
)
[image_id] => 12
)
[9] => Array
(
[attributes] => Array
(
[attribute_pa_color] => green
[attribute_pa_size] => m
[attribute_height] => 10
)
[image_id] => 17
)
[10] => Array
(
[attributes] => Array
(
[attribute_pa_color] => green
[attribute_pa_size] => m
[attribute_height] => 20
)
[image_id] => 17
)
[11] => Array
(
[attributes] => Array
(
[attribute_pa_color] => green
[attribute_pa_size] => m
[attribute_height] => 30
)
[image_id] => 17
)
[12] => Array
(
[attributes] => Array
(
[attribute_pa_color] => green
[attribute_pa_size] => xl
[attribute_height] => 10
)
[image_id] => 15
)
[13] => Array
(
[attributes] => Array
(
[attribute_pa_color] => green
[attribute_pa_size] => xl
[attribute_height] => 20
)
[image_id] => 15
)
[14] => Array
(
[attributes] => Array
(
[attribute_pa_color] => green
[attribute_pa_size] => xl
[attribute_height] => 30
)
[image_id] => 15
)
[15] => Array
(
[attributes] => Array
(
[attribute_pa_color] => green
[attribute_pa_size] => xs
[attribute_height] => 10
)
[image_id] => 11
)
[16] => Array
(
[attributes] => Array
(
[attribute_pa_color] => green
[attribute_pa_size] => xs
[attribute_height] => 20
)
[image_id] => 11
)
[17] => Array
(
[attributes] => Array
(
[attribute_pa_color] => green
[attribute_pa_size] => xs
[attribute_height] => 30
)
[image_id] => 11
)
[18] => Array
(
[attributes] => Array
(
[attribute_pa_color] => red
[attribute_pa_size] => m
[attribute_height] => 10
)
[image_id] => 16
)
[19] => Array
(
[attributes] => Array
(
[attribute_pa_color] => red
[attribute_pa_size] => m
[attribute_height] => 20
)
[image_id] => 16
)
[20] => Array
(
[attributes] => Array
(
[attribute_pa_color] => red
[attribute_pa_size] => m
[attribute_height] => 30
)
[image_id] => 16
)
[21] => Array
(
[attributes] => Array
(
[attribute_pa_color] => red
[attribute_pa_size] => xl
[attribute_height] => 10
)
[image_id] => 10
)
[22] => Array
(
[attributes] => Array
(
[attribute_pa_color] => red
[attribute_pa_size] => xl
[attribute_height] => 20
)
[image_id] => 10
)
[23] => Array
(
[attributes] => Array
(
[attribute_pa_color] => red
[attribute_pa_size] => xl
[attribute_height] => 30
)
[image_id] => 10
)
[24] => Array
(
[attributes] => Array
(
[attribute_pa_color] => red
[attribute_pa_size] => xs
[attribute_height] => 10
)
[image_id] => 21
)
[25] => Array
(
[attributes] => Array
(
[attribute_pa_color] => red
[attribute_pa_size] => xs
[attribute_height] => 20
)
[image_id] => 21
)
[26] => Array
(
[attributes] => Array
(
[attribute_pa_color] => red
[attribute_pa_size] => xs
[attribute_height] => 30
)
[image_id] => 21
)
)
)
)
ありがとう