English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
array_fill_keys — Fill an array with specified keys and values
array array_fill_keys ( array $keys, mixed $value );
It useskeysThe values of the array are used as keys withvalueFill the array with parameter values.
Number | Parameters and descriptions |
---|---|
1 | keys It is the array of values used as keys |
2 | value It can be a string or a value array |
It returns a filled array
<?php $ = array('f1',' 5, 10, 'b1); $a = array_fill_keys($input, 'banana'); print_r($a) ?>Test to see ‹/›
Output result:
Array ( [f1] => banana [5] => banana [10] => banana [b1] => banana )