PHP array_fill_keys() function
In this chapter you will learn:
- Definition for PHP array_fill_keys() function
- Syntax for PHP array_fill_keys() function
- Parameter for PHP array_fill_keys() function
- Example - Fill an array with values, specifying keys
Definition
The array_fill_keys() function fills an array with values for specified keys.
Syntax
PHP array_fill_keys() function has the following syntax.
array_fill_keys(keys,value);
Parameter
Parameter | Is Required | Description |
---|---|---|
keys | Required. | Key Array |
value | Required. | Specifies the value to use for filling the array |
Example
Fill an array with values, specifying keys:
<?php/*jav a 2 s . co m*/
$keys=array("a","b","c","d","j");
$a1=array_fill_keys($keys,"java2s.com");
print_r($a1);
?>
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP array_filter() function
- Syntax for PHP array_filter() function
- Parameter for PHP array_filter() function
- Example - Filter by user defined function
Home » PHP Tutorial » PHP Array Functions