Função PHP array_fill_keys()
Exemplo
Preencha uma matriz com valores, especificando as chaves:
<?php
$keys=array("a","b","c","d");
$a1=array_fill_keys($keys,"blue");
print_r($a1);
?>
Definição e uso
A função array_fill_keys() preenche um array com valores, especificando chaves.
Sintaxe
array_fill_keys(keys, value)
Valores de parâmetro
Parameter | Description |
---|---|
keys | Required. Array of values that will be used as keys |
value | Required. Specifies the value to use for filling the array |
Detalhes técnicos
Valor de retorno: | Retorna o array preenchido |
---|---|
Versão do PHP: | 5.2+ |
❮ Referência de array PHP