Wednesday, 24 September 2014

array_fill in PHP

PHP array_fill() function generates and then pass an array filled with the defined values.

Syntax:array_fill(start,number,value)

Parameters Description:
start : Required. A numeric value, defines the starting index of the key.
number : Required. A numeric value, defines the number of entries.
value : Required. defines the value to be added.

Example:

<?php
$days = array_fill( 2,3,"Sunday" );
print_r( $days );
?>

O/P:


Array (
           [2] => Sunday
           [3] => Sunday
           [4] => Sunday
         )

0 comments:

Post a Comment