array_combine()

array_combine() creates an array from an array of keys and an array of values.

Both arguments are treated as lists: their respective keys are discarded, and only their positions are used. The arrays are not sorted.

Both arguments must have the same number of elements.

array_combine() is the opposite of array_keys and array_values together.

<?php

    // adapted from the PHP manual example
    $a = ['green',  4 => 'red', 'c' => 'yellow'];
    $b = ['avocado', 'apple', 'banana'];
    $c = array_combine($a, $b);

    print_r($c);

    /**
       Array
    (
        [green] => avocado
        [red] => apple
        [yellow] => banana
    )
    */

    var_dump($a === array_combine(array_keys($a), array_values($a)));

?>

Documentation

Related : array_keys(), array_values(), array_column