Does PHP support indexed arrays?

WBOY
Release: 2023-03-16 15:44:02
Original
1894 people have browsed it

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");
Copy after login

The second way:

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

PHP Index array example

Copy after login

Output result:

Does PHP support indexed arrays?

File: array2.php

Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template