Jump to: navigation, search

PHP Array Functions

From w3cyberlearnings
# Function Description
1 array_change_key_case Changes all keys in an array to lower case or upper case.
2 array_chunk Split an array into chunks for a new array
3 array_combine Creates an array by combining one array for keys and another for its values
4 array_count_values Counts all the values of an array where the key is the array values and the value is the number of occurrences.
5 array_diff_assoc Compares two or more arrays, use the first array for the comparison. Return an array with the keys and value pair if the first array do not present in any of the other arrays.
6 array_diff_key Compares two or more arrays using keys for comparison
7 array_diff_uassoc Compares two or more arrays by using the user supply callback function. It returns the keys and values from the first array, when the function is matched.
8 array_diff_ukey Compares two or more arrays by using a callback function on the keys for comparison
9 array_diff Compares two or more arrays, and only return the keys and values from the first array when only the first array values are not present in all other arrays.
10 array_fill Fill an array with values by user supply.
11 array_filter Filters elements of an array using a callback function, only return the array when the array value satisfy the callback function.
12 array_flip Make array keys to be value and array value to be key.
13 array_intersect_assoc Compares two or more arrays by using the first array. Return only the first array with key and value pair when the first array present in all of the other arrays.
14 array_intersect_key Computes the intersection of arrays using keys for comparison. This function uses the first array to check with all other arrays.
15 array_intersect_uassoc Compares two or more arrays by using the first array. Return only the first array with key and value pair when the first array key is satisfy in the user defined function.
16 array_intersect_ukey Compares the intersection of arrays using keys for comparison with the user callback function. This function uses the first array to check with all other arrays based on the callback function.
17 array_intersect Compares the intersection of arrays based on the first array. Return key and value pairs of the first array when the array value is present in all the other arrays.
18 array_key_exists Checks if the given key or index exists in the array
19 array_keys Return all the keys or a subset of the keys of an array
20 array_map Use the callback function for each array value, and return a new array based on the callback function.
21 array_merge_recursive Merge two or more arrays recursively into one array. When the array has the same key, instead of override the keys, the function makes the value as an array.
22 array_merge Merge one or more arrays into one array. Array keys will be override when it is a duplicate key.
23 array_multisort Sort multiple or multi-dimensional arrays
24 array_pad Pad array to the specified length with a value
25 array_pop Pop the element off the end of array
26 array_product Calculate the product of values in an array
27 array_push Push one or more elements onto the end of array
28 array_rand Pick one or more random entries out of an array
29 array_reduce Iteratively reduce the array to a single value using a callback function
30 array_replace_recursive Replaces elements from passed arrays into the first array recursively
31 array_replace Replaces elements from passed arrays into the first array
32 array_reverse Return an array with elements in reverse order
33 array_search Searches the array for a given value and returns the corresponding key if successful
34 array_shift Shift an element off the beginning of array
35 array_slice Extract a slice of the array
36 array_splice Remove a portion of the array and replace it with something else
37 array_sum Calculate the sum of values in an array
38 array_udiff_assoc Computes the difference of arrays with additional index check, compares data by a callback function
39 array_udiff_uassoc Computes the difference of arrays with additional index check, compares data and indexes by a callback function
40 array_udiff Computes the difference of arrays by using a callback function for data comparison
41 array_uintersect_assoc Computes the intersection of arrays with additional index check, compares data by a callback function
42 array_uintersect_uassoc Computes the intersection of arrays with additional index check, compares data and indexes by a callback functions
43 array_uintersect Computes the intersection of arrays, compares data by a callback function
44 array_unique Removes duplicate values from an array
45 array_unshift Prepend one or more elements to the beginning of an array
46 array_values Return all the values of an array
47 array_walk_recursive Apply a user function recursively to every member of an array
48 array_walk Apply a user function to every member of an array
49 array Create an array
50 arsort Sort an array in reverse order and maintain index association
51 asort Sort an array and maintain index association
52 compact Create array containing variables and their values
53 count Count all elements in an array, or something in an object
54 current Return the current element in an array
55 each Return the current key and value pair from an array and advance the array cursor
56 end Set the internal pointer of an array to its last element
57 extract Import variables into the current symbol table from an array
58 in_array Checks if a value exists in an array
59 key Fetch a key from an array
60 krsort Sort an array by key in reverse order
61 ksort Sort an array by key
62 list Assign variables as if they were an array
63 natcasesort Sort an array using a case insensitive "natural order" algorithm
64 natsort Sort an array using a "natural order" algorithm
65 next Advance the internal array pointer of an array
66 pos Alias of current
67 prev Rewind the internal array pointer
68 range Create an array containing a range of elements
69 reset Set the internal pointer of an array to its first element
70 rsort Sort an array in reverse order
71 shuffle Shuffle an array
72 sizeof Alias of count
73 sort Sort an array
74 uasort Sort an array with a user-defined comparison function and maintain index association
75 uksort Sort an array by keys using a user-defined comparison function
76 usort Sort an array by values using a user-defined comparison function

Related Links

Navigation
Web
SQL
MISC
References