fillArray
method fills specified elements in an array with a value. overwrites the original array.
Start and end position can be specified. If not, all elements will be filled.
Syntax
fillArray
Returns
returns (array) changed source array
Parameters
- array_source (array)
- source array
- value (var)
- The value to fill in.
- start (integer)
- Optional. The start index (position). Default is 0.
- end (integer)
- Optional. The stop index (position). Default is array length.
Usage
example:
echo(objectToString(fillArray([0,1,2,3,4,5], 7, 2, 5)));
output: [ 0, 1, 7, 7, 7, 5 ]