PHP array_fill_keys()Functions

PHP Array ReferenceComplete PHP Array Reference Manual

Examples

Fill an array with values, using the specified keys:

<?php
$keys=array("a","b","c","d");
$a1=array_fill_keys($keys,"blue");
print_r($a1);
?>

Run example »

Definition and Usage

The array_fill_keys() function fills an array with values, using the specified keys.


Syntax

array_fill_keys(keys,value);

Parameter Description
keys Required. An array whose values will be used as keys to fill the array.
value Required. Specifies the values to use for filling the array.

Technical Details

Return value: Returns the filled array.
PHP Version: 5.2+


PHP Array ReferenceComplete PHP Array Reference Manual Other Extensions