Php (8) PHP array

Source: Internet
Author: User
I. Overview of Arrays 1. the essence of arrays: managing and operating a group of variables. batch processing 2 arrays are composite types. 3 arrays can store data of any length, you can also store any type of data. 2. there are two types of array index arrays in array classification 2PHP: subscript is sequence 1. Array Overview 1. the essence of arrays: managing and operating a group of variables, batch processing 2. array is composite type 3. the array can store data of any length or any type of data. 2. array classification. there are two array index arrays in PHP: the subscript is an ordered integer and the index is associated with the array: the subscript is a string as an index example: index array [php] $ user [0] = 1; $ user [1] = "kobe"; $ user [2] = 10; $ user [3] = "mac"; $ user [4] = "kobe@bb.com"; echo'
';  print_r($user);  echo '
'; Example: join array [php] $ user = array ("id" => 1, "name" => "kobe ", "age" => 10,100 => "mac", "kobe@bbb.com"); for ($ I = 0; $ I <20; $ I ++) $ user [] = $ I; echo'
';  print_r($user);  echo '
'; Php multi-dimensional array [php] $ User = array ('Zhang 3', 93), array ('li 4', 80), array ('Wang 5 ', 98); php array element traversal [php] "Kobe", 1 => "mac-t", 2 => "lin"); // use the first method to traverse the array foreach ($ arr as $ value) {echo "Value: $ value;";} echo"
"; // Use the second method to traverse the array foreach ($ arr as $ key => $ value) {echo" Key: $ key; Value: $ value; ";}?> [Php] Array (5 => 100, 3 => 120, 4 => 30), "ar2" => array (4 => "three", 9 => "four ", 1 => "five"); // traverses the array foreach ($ array as $ v1) {foreach ($ v1 as $ v2) {print "$ v2/n" ;}}?>

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.