array_fill_keys() function in php || PHP Functions
×


array_fill_keys() function in php

1730

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

  1. $key is an user define array which elements used by function as array keys.
  2. $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:




Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments