Overview of the php array and its classification and declaration code demonstration
<?php/**** 1 Overview of arrays1. The nature of arrays: management and manipulation 1 Group variables, batch processing2. An array is a compound type3. You can store data of any length in an array. You can also store any type of data4. Arrays perform the functions of data structures in other languages (linked lists, queues, stacks, collection classes)**2. Classification of arrays There are multiple units in an array (units are called elements) Each element is composed of subscripts [keys] and values When accessing elements individually, they are all accessed by subscript [key]1.1 Dimensional array . 2 Dimensional array, 3 Dimensional array . Multidimensional array An array of arrays is an array in which there are other arrays.2.php There are two types of arrays Indexed array: the index where the subscript [key] is a sequence of integers An associative array : the subscript is the string as the index There are only two subscripts (integers, strings)*3 . Arrays are declared in many ways1 Assign values directly to the array elements If the index index is not given, it will be given from 0 Starting index If you give me the index index 1 I'm going to start with the largest 1 If there's a subscript in front of it, if it's an assignment, it's a re-assignment of the previous elementd The time index and association of the mixed declaration do not affect each other ( Does not affect the declaration of index subscripts )2 use array() functiona The default is an indexed arrayb . If you subscript associative and indexed arrays, use keys => valuec Use ", "to split between multiple members;3 Use other function declarationsfile();******/echo $arr[5]// The index array$user[]=1;$user[9]=" zhang 3"$user[0]=10;$user[3]="nan";$info=array("$user"=array(//$user[0]array("1"," zhang 3",10,"nan"),//$user[1]array("2","lisi",10,"nan"),//$user[2]array("3","wangwu",10,"nan"),),"$score"=array(//$user[0]array("1"," zhang 3",10,"nan"),//$user[1]array("2","lisi",10,"nan"),//$user[2]array("3","wangwu",10,"nan"),),"$connect"=array(//$user[0]array("1"," zhang 3",10,"nan"),//$user[1]array("2","lisi",10,"nan"),//$user[2]array("3","wangwu",10,"nan"),),};$user[][]=1;$user[][]=1;$user[][]=1;$user[][]=1;$user[][]=1;?>