PHP将多维数组合并为一个

I need to amend the following array:

Array
(
    [category_id] => Array
        (
            [0] => 21
            [1] => 22
        )

    [amount] => Array
        (
            [0] => 10000
            [1] => 2000
        )

)

I need to get the output to look like this:

Array
(
    [0] => Array
        (
            [category_id] => 21
            [amount] => 10000
        )

    [1] => Array
        (
            [category_id] => 22
            [amount] => 2000
        )

)

Does anyone know how to achieve this?

Try -

$array = array
(
    'category_id' => array
        (
            '0' => 21,
            '1' => 22
        ),

    'amount' => array
        (
            '0' => 10000,
            '1' => 2000
        )

);

$new = array();

$keys = array_keys($array);
$elements = 2;

for($i = 0; $i < 2; $i++) {
    $temp = array_column($array, $i);
    $new[] = array_combine($keys, $temp);
}

var_dump($new);

Output

array(2) {
  [0]=>
  array(2) {
    ["category_id"]=>
    int(21)
    ["amount"]=>
    int(10000)
  }
  [1]=>
  array(2) {
    ["category_id"]=>
    int(22)
    ["amount"]=>
    int(2000)
  }
}

array_column() supported PHP >= 5.5

array_combine()

Fiddle