Web | This Site

Learning PHP
Advanced PHP
PHP Function Reference
PHP Useful Resources
Selected Reading
© 2011 TutorialsPoint.COM

| Home |  | References |  | Discussion Forums |  | About TP

# PHP Function array_combine()

## Syntax

array array_combine ( array $keys, array $values );

## Definition and Usage

Creates an array by using the values from the keys array as keys and the values from the values array as the corresponding values.

## Paramters

Parameter | Description
--- | ---
keys | Array of keys to be used
values | Array of values to be used

## Return Values

Returns the combined array, FALSE if the number of elements for each array isn't equal or if the arrays are empty.

## Example

Try out following example:

    <?php
    $a = array('green', 'red', 'yellow');
    $b = array('avocado', 'apple', 'banana');
    $c = array_combine($a, $b);

    print_r($c);
    ?>

This will produce following result:

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

Advertisement

Online Image Processing

Indian Baby Names