PHP array_combine()

array_combine() is used to create a combined array from two arrays having an equal number of elements. Elements in one array become keys and elements of another array become values of the new combined array.

For example: Take two arrays having equal no of elements

$keys = ['car','book','weapon','ocean']; // 1st array having 4 values 
$values = ['BMW','Let US C','Gun','Indian Ocean']; //2nd array having 4 values 
$combined = array_combine($keys,$values); 

The OutPut of This this code snippet is :

    [car] => BMW
    [book] => Let US C
    [weapon] => Gun
    [ocean] => Indian Ocean

Run the above code and check the result.

Spread the love
Your Result displays here
Memory: Memory Usage, CPU Time: CPU Usage