Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

array_fill()

Example

Populate an array with values:

<?php
$a1=array_fill(3,4,“blue”);
print_r($a1);
?>

Definition and Usage

The array_fill() function populates an array with specified values.

Syntax

array_fill(index, number, value)

Parameter Values

Parameter

Description

index

Required. The first index of the returned array

number

Required. Specifies the number of elements to insert

value

Required. Specifies the value to use for filling the array

Technical Details

Return Value:

Returns the filled array

PHP Version:

4.2+