从多维数组计算Distict值

时间:2017-01-26 05:53:12

标签: php multidimensional-array

示例数组:

Array
(
    [0] => Array
        (
            [campain] => exaple1
            [subject] => subject1
            [count] => 1
        )

    [1] => Array
        (
            [campain] => exaple2
            [subject] => subject2
        )

    [2] => Array
        (
            [campain] => exaple3
            [subject] => subject3
        )

    [3] => Array
        (
            [campain] => exaple1
            [subject] => subject1
        )

    [4] => Array
        (
            [campain] => exaple2
            [subject] => subject2
        )

    [5] => Array
        (
            [campain] => exaple1
            [subject] => subject1
        )
)

预期结果:

Array
(
    [0] => Array
        (
            [campain] => exaple1
            [subject] => subject1
            [count] => 3
        )

    [1] => Array
        (
            [campain] => exaple2
            [subject] => subject2
            [count] => 2
        )

    [2] => Array
        (
            [campain] => exaple3
            [subject] => subject3
            [count] => 1
        )
)

需要独特的campain,subject&坎贝恩伯爵。主体价值可以被忽略(我的意思是不需要考虑主题价值,因为它的价值不会因为坎普而改变。)

0 个答案:

没有答案