Fill an array with the given key value:
<?php$keys=array("a","b","c","d");$a1=array_fill_keys($keys,"blue");print_r($a1);?>The array_fill_keys() function fills an array with the key values given by the specified key name.
array_fill_keys( keys,value );
parameter | describe |
---|---|
keys | Required. Array whose values will be used to populate the array keys. |
value | Required. Specifies the key values used to populate the array. |
Return value: | Returns the populated array. |
---|---|
PHP version: | 5.2+ |