Latest web development tutorials

PHP array_fill_keys () function

PHP Array Reference Complete PHP Array Reference

Examples

Fill an array with the keys given a specified key:

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

Running instance »

Definition and Usage

array_fill_keys () function fills an array with the keys given a specified key.


grammar

array_fill_keys( keys,value );

参数 描述
keys 必需。数组,其值将被用于填充数组的键名。
value 必需。规定用于填充数组的键值。

technical details

return value: Returns an array of fill.
PHP version: 5.2+


PHP Array Reference Complete PHP Array Reference