Home >Backend Development >PHP Problem >Does PHP support indexed arrays?

Does PHP support indexed arrays?

WBOY
WBOYOriginal
2022-07-22 15:12:351922browse

PHP supports index arrays; index arrays are also called numerical arrays. By default, they are represented by index numbers. All elements of the array are represented by index numbers starting from 0. Index arrays can store numbers and characters. String or any object, you can use "$array=array("array element", "array element"...);" to define an index array.

Does PHP support indexed arrays?

The operating environment of this article: Windows 10 system, PHP version 8.1, Dell G3 computer

PHP supports index array

PHP An indexed array is an array, represented by index numbers by default. All elements of the array are represented by index numbers starting from 0.

PHP index array can store numbers, strings or any object. PHP indexed arrays are also known as numeric arrays.

Definition There are two ways to define an index array:

The first way:

$size=array("Big","Medium","Short");

The second way:

$size[0]="Big";  
$size[1]="Medium";  
$size[2]="Short";

PHP Index array example

Output result:

Does PHP support indexed arrays?

File: array2.php

Output result:

Does PHP support indexed arrays?

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of Does PHP support indexed arrays?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn