PHP array function re-learning
Divide the array $ arr into n arrays, and put it in a two-dimensional array. the returned value is a two-dimensional array. The third parameter indicates whether to retain the original subscript "$ arr = array (" key1 "=>" value1 ", "key2" => "value2", "key3" => "value3", "key4" => "value4",); array_chunk ($ arr, 2, true ); array_count_values ($ arr) counts the number of occurrences of the $ arr value. // select count (user) from t group by user; same meaning "### get array difference/intersection" array_diff ($ arr1, $ arr2, $ arr3 ...) // (compare only values) $ arr1-$ arr2-$ arr3 -... // ['A', 'B', 'C']-['C', 'B ', 'D'] => ['A'] array_diff_assoc // compare subscript and value ar Ray_diff_key // compare key (subscript) array_diff_ukey ($ arr1, $ arr2, $ arr3 ..., function) array_diff_uassoc ($ arr1, $ arr2, $ arr3 ..., function) // Yes => array_udiff series: returns the result set with the index. // Yes => array_uintersect () Series: returns the intersection. // Yes => array_intersect () "### general content operations ** fill the array with the given value. ** Specify the subscripts for $ arr to start the given value and append N $ arr = array_fill (start, num, value); "print_r ($ arr1 = array_fill (5, 3, "ss"); "** fill the array with a value to the specified length ** is equivalent to the array initialization length of num, adding a value to the array already has an append length to num "array_pad ($ arr, num, value);" ** search for a given value in the array, if the operation succeeds, the corresponding key name is returned. ** If "array_search (value, $ arr, strict) specifies strict (true, false), the data type is verified." ***** "array_sum ($ arr) calculates the sum of all values in the array. Array_product ($ arr) calculates the product of the array value. array_rand ($ arr) retrieves the Array Value. array_reverse ($ arr) reverses the array array_shift ($ arr) delete the first element of the array and return its value array_slice ($ arr, offset, length, preserve). The value of the length truncated by offset specifies the preserve to retain the subscript array_splice ($ arr, offset, length, $ arr1) in $ arr, the value of the length truncated by offset is replaced by arr1. "** the function imports the variable from the array to the current symbol table **" extract (array, extract_rules, prefix) $ a = 'original'; $ my_array = array ("a" => "Cat", "B" => "Dog ", "c" => "Horse" ); Extract ($ my_array); echo "\ $ a = $ a; \ $ B = $ B; \ $ c = $ c"; output: $ a = Cat; $ B = Dog; $ c = Horse "** check whether the content exists **" in_array (value, array, [type]) "### the callback series traverses the $ arr array element in the func function and returns the value returned by the expected (filter array) func: BOOLEAN" array_filter ($ arr, func ); "** function the callback function to the unit of the given array ** the string returned by func replaces the original returned value with an array" array_map (func, $ arr1, $ arr2, $ arr3 ......); "** use the callback function to iteratively simplify the array to a single value **. process the array according to the method in func to return a string, and add the first connector specified for inbetween as inbetween, the result is to concatenate the return values of all segments. "Array_reduce ($ arr, func, inner)" array_walk (array, function, userdata ...) function has three parameters, the first two are required, $ key, $ value, and the third is optional. "Function myfunction ($ value, $ key) {echo" The key $ key has the value $ value
";}$ A = array (" a "=>" Cat "," B "=>" Dog "," c "=>" Horse "); array_walk ($ a, "myfunction"); // array_assist_recursive recursive call "and the sorting series will not be viewed.