|
|
Php Array Function array_fill_keys()
|
Tutorials » Php »
|
Topic |
What is array_fill_keys() Function?
|
|
Explanation |
|
The "array_fill_keys()" function is used fill an array with values,by specifying the keys.
Syntax:
array_fill_keys(array,value)
In the above syntax "array" is the array to be filled with the values provided in "value".
Example
<?php
$b = array('food', 5, 10, 'bar');
$a = array_fill_keys($b, 'fruit');
print_r($a);
?>
Result:
Array
(
[food]=> fruit
[5] => fruit
[10] => fruit
[bar] => fruit
)
In the above example array is filled for the specified keys. The keys are food, 5, 10, bar, are filled
with the string 'fruit'.
|
|
A Note |
Learn PHP programming language tutorial with simple and neat example. Hope you enjoy this free tutorial.
Do give us your valuable feedback and suggestions on this online tutorial. This is a Copyright Content.
|
|
|
|