Bladephp: Now with 8+ codeigniter, php, and laravel project 8+ php project From $37/Month From Rs. 2499/Month

PHP array_fill_keys() Function

by
Category:php
php php array function
PHP array_fill_keys() Function

It fills an array with the value of the value parameter, using the values of the keys array as keys.

The function array_fill() is used to assign or fill mixed values to an array by declaring suitable number of elements in the array. Whereas the function array_fill_keys() is used to fill mixed values to an array corresponding to the key values.

Parameter Description
keys Required. Array of values that will be used as keys
value Required. Specifies the value to use for filling the array

Syntax

array_fill_keys(keys,value);

Example

$keys=array("a","b","c","d");
$array=array_fill_keys($keys,"Prince");
print_r($array);

Output

Array ( [a] => Prince [b] => Prince [c] => Prince [d] => Prince ) 

0 Comments


Html code work in comment box


Related Post