|
Php |
ECMAScript |
Length |
$length = count ($array) |
Length = Array.Length |
|
|
|
Increase |
Array_unshift ($array, NEW1,NEW2) adds one or more elements at the beginning, returning the length |
Array.unshift (NEW1,NEW2) |
|
Array_push ($array, new1,new2) The tail adds one or more elements, returning the length |
Array.push (NEW1,NEW2) |
|
|
|
By deleting |
Array_shift ($array) Delete and return the first element |
Array.shift () |
|
Array_pop ($array) Delete and return the last element |
Array.pop () |
|
|
|
Check |
In_array (value, $arrary) to see if the element is in the array $arr |
|
Pointer |
Key ($array) Gets the subscript that the current array pointer points to |
|
|
Array_keys ($array) gets all the subscript of the element, returns the index value |
|
|
Current ($array) gets the element that is pointed to by this array pointer |
|
|
Array_values ($array) to convert an associative array to an indexed array |
|
|
The Pre ($arr) returns the previous element pointed to by the current pointer, and the pointer moves forward |
|
|
Next ($arr) returns the last element pointed to by the current pointer, and the pointer moves back |
|
|
Reset ($arr) resets the pointer to the first element and returns the first element |
|
|
End ($arr) resets the pointer to the end element and returns the end element |
|
|
|
|
Order |
Array_reverse ($array, [True/false]) reverses the array, by default true, preserving the original key name |
Arr.reverse () array inversion, changing the original array |
|
Sort ($array, sorttype) sorted in ascending order, regenerate key name, SortType sort mode |
Arr.sort (sortby) SortBy Optional sort order, must be a function |
|
Shuffle ($array) scrambled array |
|
|
|
|
Merge |
Implode (separator, $array) array connection is string, default Separateor is empty |
Arr.jion (separator) separator that the comma |
|
Array_merge ($arr 1, $arr 2, $arr 3) index subscript full reset, associated subscript same latter covering the former |
Arr1.contact (ARR2,ARR3) |
|
Note: $arr 1+ $arr 2 array Merge, the subscript is the same, the latter ignores |
|
|
|
|
Intercept |
Array_slice ($array, start, [length], [True/false]) returns an array of specified position lengths, by default true to hold the key name |
Arr.slice (start, [end]) returns an array of the specified positions |
|
|
|
Delete/Add |
Array_splice ($array, start, [Length],[array]) deletes the specified position length element and adds a new array |
Arr.splice (start, length, [value1,value2]) added as an element, returning the array of elements that were deleted |
|
|
|
New |
Range (min, max, [step]) generates an array from min to max, increasing the cloth width to step |
|
|
Array_rand ($array, N) randomly extracts the subscript of n elements in the specified array |
|
|
|
|
Traverse |
foreach ()/list () mates each () |
For in |