How to use array fill in PHP
In this article, I will explain how the array_fill() function can be used in PHP.
array_fill() function in PHP
-
The array_fill() function is used to fill an array with values.
-
In array_fill() function, keys starting at the start parameter.
Syntax
array_fill(start,number,value) |
Parameter
-
start start is the required parameter. A numeric value, specifies the starting index of the key.
-
number number is the required parameter. A numeric value, determine the number of elements to insert.
-
value value is the required parameter. the value to be use filling.
Example
The following example show to how the array_fill() function can be used in PHP.
<html>
<body>
<h3 style="color: darkorchid;">array_fill() function example in PHP</h3>
<?php
$a = array_fill(5, 6, 'Welcome to C-sharpcorner<br/>');
print_r($a);
?>
</body>
</html>
|
Output
You may also want to read these related articles here
Ask Your Question
Got a programming related question? You may want to post your question here