basic functions of array manipulationarray_values($arr);//get the value of an array Array_keys($arr);//get the key name of the array Array_flip($arr);//the values in the array are interchanged with the key names (if there are duplicates, the previous overrides will be followed) Array_search(' PHP ',$arr);//retrieves the given value, plus true is the strict type check Array_reverse($arr);//flips the elements in the array In_array("Apple",$arr);//retrieving an apple in an array array_key_exists("Apple",$arr);//retrieves whether the given key name exists in the array array_count_values($arr);//Count The number of occurrences of all values in the arrayii. Segmentation and padding of arraysArray_slice($arr, 0, 3);//you can take a paragraph out of the array, which ignores the key name (the fragment of the array) Array_splice($arr, 0, 3,Array("Black", "maroon"));//you can take a paragraph out of an array, unlike the previous function, in which the returned sequence is removed from the original array . Array_chunk($arr, 3,TRUE);//You can split an array into multiple, true to preserve the key name of the original array (splitting multiple arrays)iv. arrays and stacks, queued www. bcty365.comArray_push($arr, "Apple", "pear");//presses one or more elements into the end of the array stack (into the stack), returning the number of elements in the stack Array_pop($arr);//pops the last element of the array stack (out of the stack) Array_shift($arr);//The first element in the array is moved out and returned (array length minus 1, other elements move forward one bit, number key name changes from zero count, text key name does not change) Array_unshift($arr, "a",Array());//inserts one or more elements at the beginning of an arrayvi. Ordering of arraysSort($arr);//from small to large, ignoring the key name Rsort ($arr); From large to small, ignoring key names Asort($arr);//from small to large, keep the key name Arsort ($arr); From big to small, keep key names Ksort($arr);//sort Krsort ($arr) in positive order by key name; Sort by key name in reverse ordervii. Calculation of arraysArray_sum($arr);//sums all elements inside an array (the sum of the elements of a sequence) Array_merge(ARR1,ARR2);//Merge two or more (the same string key name, followed by the same numeric key name, followed by append to the back) Array_diff(ARR1,ARR2);//returns an array of difference results array_diff_assoc (ARR1,ARR2, $arr 3); Returns the array of difference results, and the key names are also compared Array_intersect(ARR1,ARR2);//returns the intersection result array Array_intersect_assoc (ARR1,ARR2); Returns an array of intersection results, with key names also being comparedeight, other array functionsArray_unique($arr);//removes duplicate values from the array, preserving the original key names in the new arrays Shuffle($arr);//disturb the order of the arrays
PHP array functions common to those