Current Location: Home> Function Categories> array_fill_keys

array_fill_keys

Fill the array with specified keys and values
Name:array_fill_keys
Category:Array
Programming Language:php
One-line Description:Fill the array with the given key value of the specified key name.

Definition and usage

array_fill_keys() function fills the array with the specified key and value.

Example

Fill the array with specified keys and values:

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

Try it yourself

grammar

 array_fill_keys ( keys , value ) ;
parameter describe
keys Required. Use the value of this array as the key. Illegal values ​​will be converted to strings.
value Required. The value used to fill the array.
Similar Functions