从具有不同值的相同键创建数组[关闭]

I need to recreate an array from an array in combining the same key and puting in their values ..ok its not clear, here is a concret exemple:

i have this array1 bellow :

Array1
(
    [0] => Array
        (
            [profile_field_id] => 214
            [value] => 1
            [order] => 1
        )

    [1] => Array
        (
            [profile_field_id] => 214
            [value] => 2
            [order] => 2
        )

    [2] => Array
        (
            [profile_field_id] => 214
            [value] => 4
            [order] => 3
        )

    [3] => Array
        (
            [profile_field_id] => 214
            [value] => 8
            [order] => 4
        )

    [4] => Array
        (
            [profile_field_id] => 215
            [value] => 1
            [order] => 1
        )

    [5] => Array
        (
            [profile_field_id] => 215
            [value] => 2
            [order] => 2
        )

and i need to create an array from array1 , the output should be:

Array
(
    [214] => Array
        (

            [value] => Array
            (
             [1]
             [2]
             [4]
             [8]

            )

        )

    [215] => Array
        (
            [value] => Array
            (
             [1]
             [2]


            )
        )

Thanks for your help, Jess

I think this is what you're looking for:

$array2 = array();                                                                  
foreach($array1 as $key => $value)                                                  
{                                                                                   
  $array2[$value['profile_field_id']]['value'][$value['value']] = $value['value'];                                                                                                                                                                                                                                             
}

with your dataset, it outputs this for me:

Array
(   
    [214] => Array
        (   
            [value] => Array
                (   
                    [1] => 1
                    [2] => 2
                    [4] => 4
                    [8] => 8
                )

        )

    [215] => Array
        (   
            [value] => Array
                (   
                    [1] => 1
                    [2] => 2
                )

        )

)

To change the output from identical key/value pairs, remove the first $value['value'] from the left side of the assignment.