Home > Article > Backend Development > Does PHP support indexed arrays?
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.
The operating environment of this article: Windows 10 system, PHP version 8.1, Dell G3 computer
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:
File: array2.php
Output result:
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!