Copy Code code as follows:
var beatles = ["John", "Paul", "George", "Ringo"];
The Beatles array above is a typical example of a traditional array: the subscript for each element is a number, and the number increases by 1 for each
In PHP, arrays are grouped into two categories: Numeric index arrays and associative arrays. Where the numeric index array is the same as the array in C language, subscript is for 0,1,2 ... An associative array subscript may be any type, similar to
perl| Function | Array describes the very useful "array" functions in several PHP4
1 void Extract (array var_array [, int extract_type] [, string prefix]])
Expands an associative array to the variable name and the value of the variable, and if
A foreach loop is used to traverse a two-dimensional indexed array, which is relatively faster and more efficient, and the Foreach loop is specifically used in PHP for looping arrays.Examples are relatively simple, more practice, to understand the
var privarr = [];
privarr[' staprojquerygrid '] = [{
btn_id: ' But_add ',
roles: [' 2001 ', ' the ' of the '] ']
console.log (Privarr, PRIVARR.STAPROJQUERYGRID[0].BTN_ID)
The first line is to define an array Priarr, and the
Numeric arrayThe numeric array stores each element with a numeric ID key.
You can use different methods to create an array of values:
Example 1In this example, the ID key is assigned automatically:
The code is as follows
Copy Code
var n = {1:100, 2:101, 3:102, 4:103};How to get the length of this object n?Method One:function GetLength (obj) {var count = 0;for (var i in N) {count++;}return count;}Improvement plus a hasOwnProperty judgment filter the properties in the prototype
With regard to array ordering, PHP has a built-in shuffle () function that can rearrange array ordering, but this function "removes the original key name and not just the reorder", and if the associated array is passed in, the key name of the
Shell implementation Associative array
Shell implementation Associative arrayWrite the input and output of the array with the shell; there is a file, the first list of host names, the second column IP address, how to enter the hostname return IP
Example:$arr = [[' SS ' =>4, ' name ' = ' I '],[' SS ' =>1, ' name ' = ' B '],[' SS ' =>2, ' name ' = ' C '],[' SS ' =>7, ' name ' = ' a '],[' SS ' =>3, ' name ' = ' You ']];For example, I want to sort by the value of name, sort by Pinyin
The example of this article describes the method by which the PHP associative array implementation deletes elements based on element values. Share to everyone for your reference. Specifically as follows:
?
1 2 3 4 5 6 7
"green",
IntroductionPreviously said can be associated with the server to remove some of the dynamic changes in the information, the previous also mentioned in Web_reg_save_param can be set Ord=all, represents a list from the server is an array, the trial
The example in this article describes how PHP uses Asort () to sort associative arrays by value. Share to everyone for your reference. The specific analysis is as follows:
PHP uses Asort () to sort the associative array by value, and the difference
in PHP, arrays are divided into two categories: numbersIndex
arrays and associative arrays.
Where the numeric index array is the same as the array in the C language, the subscript is for 0,1,2 ...Associative array subscripts may be of any type,
Shell implementation Associative array
Shell implementation Associative arrayWrite the input and output of the array with the shell; there is a file, the first list of host names, the second column IP address, how to
make use variables as an array index see examplesExample$CatEmployeesTom Jones44245/ A/ the543354Mary Adams5346 One/4/ the28765Sally Chang16547/ A/ Wu650000Billy Black.16839/ at/ -336500$ awk' {name[x++]=$2}end{for (i=0; iEmployees0Jones1Adams2Chang3
Shell implementation Associative array
Shell implementation Associative arrayWrite the input and output of the array with the shell; there is a file, the first list of host names, the second column IP address, how to enter the hostname return IP
Fourth. Arrays, associative arrays, and aliases using array noun explanationsarrays, as a special kind of data structure, have their place in any programming language, and arrays are a very important part of the shell script, which uses indexes to
1. Adding array elements
PHP is a weak type language, which means you don't need to display an array and its size, instead, you can declare and populate the array at the same time. If you are working on a digital index array, you may want to use
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.