array_fill_keys() function in php
Last Updated by Pooja Chikara
0 2454
array_fill_keys() function of PHP is used to fill an array with values by defining the keys of array. It is an inbuilt function of PHP.
Syntax:
array_fill_keys ($key,$arr_value);
Here
- $key is an user define array which elements used by function as array keys.
- $arr_value represents the value of array elements.
Example:
<?php
$key=array("fruit1","fruit2","fruit3","fruit4","fruit5","fruit6");
$value="Mango";
$arr1=array_fill_keys($key,$value);
echo "<pre>";
print_r($arr1);
?>Output:

Share:
Recommended Topics:
You May Also Like
PHP Examples
News letter
Subscribe To Never Miss an Article From

Comments
Waiting for your comments