Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use the array_fill function in php

Shulou Source: shulou.com Published: 2022-05-31 10:57:00 09月17日 Update

This article mainly explains "how to use the array_fill function in php". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use the array_fill function in php".

1. Description

The array_fill () function is used to populate an array of n elements from a given index with a given index.

2. Grammar

Array_fill (index,number,value)

3. Parameters

Index is required. Specifies the starting index of the returned array.

Number is required. Specifies the number of elements to be populated, with a value greater than 0.

Note:

(1) number can enter version 0. 5. 5 and below will return a notice error. Version 5. 6 or above will return a normal result.

(2) when number is 0, version 5.5 returns false, while versions 5.6 and above return an empty array

Value

4. Return value

Returns the filled array.

5. Examples

Input: index = 3n = 5 value = "Okay" Output: Array ([3] = > Okay [4] = > Okay [5] = > Okay [6] = > Okay [7] = > Okay) Thank you for reading. This is the content of "how to use array_fill functions in php". After the study of this article, I believe that you have a deeper understanding of how to use the array_fill function in php, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Functions arrays versions indexes learning elements content parameters examples that is ideas situations quantity articles more knowledge knowledge points articles results grammar Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Apple MySQL OPPO Reno Redmi