将数组的值配对到新的键值对数组[重复]

This question already has an answer here:

I have an array that looks like this:

Array (
    [0] => Array ([order_variable_key] => surname [order_variable_value] => Hudsons )
    [1] => Array ( [order_variable_key] => number [order_variable_value] => 13 )
    [2] => Array ( [order_variable_key] => firstname [order_variable_value] => Dave )
)

I want to convert it to an array that looks like this:

Array(
    'surname' => Hudsons,
    'number' => 13,
    'firstname' => Dave);

I managed to isolate the values but was not able to pair them with eachother. I want to pair the values of the nested array with eachother.

</div>

you can use

$newArray = array();
foreach($array as $obj)
{
   $newArray[$obj['order_variable_key']] = $obj['order_variable_value']
}   

Try this:

$arr = // your array;

$data = array();
foreach($arr as $val)
{
    $arr[$val['order_variable_key']] = $val['order_variable_value'];
}

print_r($arr);

will give your desired format.

$new_array= array();
foreach($array_name1 as $key=>$val){
    $new_array[$val['order_variable_key']] = $val['order_variable_value'];
}