What is a PHP one-dimensional array? php one-dimensional array example

Source: Internet
Author: User
Tags array example
What is a PHP one-dimensional array?

A one-dimensional array is a single array of structures arranged in a simple sort structure, consisting of numbers. Is the basis of a two-dimensional array and a multidimensional array.

An array is a collection of several variables of the same type, and the same name can be used when referencing them. Arrays are composed of contiguous storage units, the lowest address corresponds to the first element of the array, the highest address corresponds to the last element, and the array can be one-dimensional or multidimensional.

PHP One-dimensional array instance detailed

One-dimensional arrays in computer languages

(1) An array is a set of ordered data. The arrangement of the data in the array is a regular one, and the subscript represents the ordinal number of the data in the array.

(2) using an array name (such as s) and subscripts (such as 14) to uniquely determine the elements in the array, such as S, represents the 15th student's grade.

(3) Each element in the array belongs to the same data type. It is not possible to put different types of data (such as students ' grades and students ' gender) in the same set of numbers.

When an element of an array is a variable, the array is called a one-dimensional array. A one-dimensional array is the most common array that saves only one column of content.

The general form of declaring a one-dimensional array is:

Examples of PHP one-dimensional arrays:

<?phpheader ("content-type:text/html; Charset=utf-8 "), $array = Array (1=>" PHP ",2=>" Chinese ",3=>" net ");p Rint_r ($array); >

The output is:

Next we will introduce "what is a PHP two-dimensional array?" PHP two-dimensional array instance detailed


"Related tutorials Recommended"

1. Related topics: "PHP array"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.