Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

array_fill_keys

Description

The array_fill_keys of Array for PHP fill an array with values, specifying keys.

Syntax

array_fill_keys ( array $keys , mixed $value ) : array

Parameters

keys

Array of values that will be used as keys. Illegal values for key will be converted to string.

value

Value to use for filling

Return

Returns the filled array

Examples

1

<?

$keys = array("a", 0, 5, "abc");
$value = "abc";

$return = array_fill_keys($keys, $value);

print_r($return);

?>
Array
(
    [a] => abc
    [0] => abc
    [5] => abc
    [abc] => abc
)
HomeMenu