Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

PHP Function array_fill()


previous

Advertisements

Syntax

array array_fill ( int $start_index, int $num, mixed $value );

Definition and Usage

Fills an array with num entries of the value of the value parameter, keys starting at the start_index parameter.

Paramters

ParameterDescription
start_indexThe first index of the returned array
numNumber of elements to insert
valueValues to use filling

Return Values

Returns the filled array

Example

Try out following example:

<?php
$a = array_fill(5, 6, 'apple');
print_r($a)
?> 

This will produce following result:

Array
(
    [5]  => apple
    [6]  => apple
    [7]  => apple
    [8]  => apple
    [9]  => apple
    [10] => apple
)

previous Printer Friendly

Advertisements


  

Advertisements