This site is mobile accessible. Press the "Tap Here" button to use a different font-size.


Smartphone icons created by Freepik - Flaticon

  • PHP array_combine() Function

  • Definition and Usage

    • The array_combine() function creates an array by using the elements from one "keys" array and one "values" array.
    • Note: Both arrays must have equal number of elements!

    Syntax

    array_combine(keys, values)

    Parameter Values

    Parameter Description
    keys Required. Array of keys
    values Required. Array of values

    Technical Details

    Return Value: Returns the combined array. FALSE if number of elements does not match
    PHP Version: 5+
    Changelog: Versions before PHP 5.4 issues E_WARNING and returns FALSE for empty arrays
    Example: PHP array_combine() Function

    Create an array by using the elements from one "keys" array and one "values" array:

    <?php
    $fname=array("Peter","Ben","Joe");
    $age=array("35","37","43");
    
    $c=array_combine($fname,$age);
    print_r($c);
    ?>
    Navigate this PHP reference guide

    Eventually the navigation links, above, will be replaced by these << (previous) and >> (next) buttons below.



    Animated PHP icons used in the buttons provided by ICONS8.COM. Smartphone icons created by Freepik - Flaticon

    PHP Quiz