array_fill_keys
Fill the array with specified keys and values
array_fill_keys()
function fills the array with the specified key and value.
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
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. |