<?php
/* Traversal of arrays
*
* 1. Iterating through an array using a For statement
* A. Other languages (only this way)
* B. This is not our preferred method in PHP
* C. The array must be an indexed array, and the subscript must also be contiguous
* (index array subscript can also be non-sequential, arrays and associative arrays)
*
*
* 2. Iterating through an array using a foreach statement
* foreach (array variable as variable value) {
*//Loop Body
* }
* A. The number of cycles is determined by the number of elements in the array
* B. Each iteration assigns the elements in the array to the following variables
*
* foreach (array variable as subscript variable = = value variable) {
*
* }
*
* 3. while () the list () each () combination loops through the array
*
* each () function,
* A. An array is required as a parameter
* B. Returned is also an array
* C. The returned array is 0, 1, key, value four subscript (fixed)
* 0 and key subscript are keys to the current parameter array element
* 1 and value subscript is the value of the current logarithmic array element
*
* d. The default is that the current element is the first element
* E. The current element is moved backwards after each execution
* F. Returns False if the function is executed again to the last element
*
*//array ([1] = 1 [value] = 1 [0] = = ID [key] + + ID)
*
* List () function
* A. List () =array (); You need to assign an array to this function
* B. The number of elements in the array to be the same as the number of parameters in the list () function
* C. Each element value in the array is assigned the value of each parameter in the list () function, and list () converts each argument to a variable
* d. List () can only receive indexed arrays
* E. Order of subscripts by index
*/
/*
$user =array ("id" =>1, "name" = "Zhangsan", "Age" =>10, "sex" = "Nan");
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.