PHP Learning Notes-Arrays (1), PHP Learning notes Array _php tutorial

Source: Internet
Author: User

PHP Learning Notes-Arrays (1), PHP Learning notes array


1-1 Array Definitions

1. What is an array?

An array is a set of elements of the same data type arranged in a certain order, that is, a variable of the same type is named with a name, and then the set of the variable is distinguished by a number, which is called the array name, and the number is called the subscript. Each variable that makes up an array is called the component of an array, also known as an element of an array, sometimes called a subscript variable.

The syntax is as follows:

 
  PHP// set a variable to an empty array    $arr=array(); >

1-2 Initialization of indexed arrays

PHP has two types of arrays: indexed arrays, associative arrays.

Indexes and associations two words are for the keys of an array.

An indexed array is an array of exponential groups whose keys are integers, and the integer order of the keys starts at 0, and so on.

 
  PHP    $num=array(+/-);     Print_r ($num[0]);? >

Output results: 1

1-3 Indexed Array Assignment

3 different methods

 
  PHP$arr[0]=1; // Method 1 $arr=array(' 0 ' =>1); // Method 2 $arr=array(1); // Method 3?>

1-4 Accessing array contents

 
  PHP// from the array variable $arr, read the value of the key 0 $arrArray(--); $arr 0=$arr[0]; Echo $arr 0 ;? >

http://www.bkjia.com/PHPjc/975063.html www.bkjia.com true http://www.bkjia.com/PHPjc/975063.html techarticle PHP Learning Notes-Arrays (1), PHP Learning notes array 1-1 array definition 1. What is an array? The so-called array is the set of elements of the same data type arranged in a certain order, that is, the limited ...

  • 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.