Fill an array with values in PHP

Description

The following code shows how to fill an array with values.

Example


/*  w  ww.  ja  va 2 s  .co m*/
<?php
    $a1=array_fill(3,4,"XML");
    print_r($a1);
    
    $a = array_fill(5, 6, 'CSS');
    $b = array_fill(-2, 4, 'HTML');
    print_r($a);
    print_r($b);    
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone