1. Array Functions that Apply a Callback
These functions allow you to apply a callback function to each element of an array.
array_map()— Applies a callback to each element of an array (creates a new array).array_walk()— Applies a callback to each element of an array (modifies the array in place).array_walk_recursive()— Applies a callback to each element of an array recursively.array_filter()— Filters elements of an array using a callback function.array_reduce()— Reduces an array to a single value using a callback function.array_flip()— Exchanges all keys and values in an array.array_column()— Returns the values from a single column of the input array.
2. Array Functions for Checking Existence
These functions are used to check if a specific element or key exists in an array.
array_key_exists()— Checks if a specific key exists in the array.array_key_first()— Returns the first key of an array.array_key_last()— Returns the last key of an array.array_search()— Searches for a value in an array and returns its key.in_array()— Checks if a value exists in an array.array_contains()(PHP 8.1 and later) — Checks if a value exists in an array.array_flip()— Flips the array (keys become values and values become keys), so you can check if a value exists as a key.array_search()— Searches for a value in an array and returns the corresponding key.array_is_list()— Checks if the array is a list (numeric keys only).
3. Array Functions for Sorting and Ordering
These functions are used to sort or manipulate the order of elements in an array.
sort()— Sorts an array in ascending order.rsort()— Sorts an array in descending order.asort()— Sorts an array in ascending order, maintaining key-value relations.arsort()— Sorts an array in descending order, maintaining key-value relations.ksort()— Sorts an array by key in ascending order.krsort()— Sorts an array by key in descending order.natsort()— Sorts an array using a natural order algorithm (numeric order).natcasesort()— Sorts an array using a natural order algorithm, ignoring case.usort()— Sorts an array by values using a user-defined comparison function.uksort()— Sorts an array by keys using a user-defined comparison function.uasort()— Sorts an array by values using a user-defined comparison function while maintaining key-value relations.
4. Array Functions for Modifying or Manipulating Arrays
These functions are used to modify arrays in various ways.
array_merge()— Merges two or more arrays into one.array_merge_recursive()— Merges arrays recursively.array_slice()— Extracts a portion of an array.array_splice()— Removes a portion of the array and optionally replaces it.array_replace()— Replaces elements of an array with elements of another array.array_diff()— Computes the difference of arrays.array_diff_assoc()— Computes the difference of arrays including keys.array_intersect()— Computes the intersection of arrays.array_intersect_assoc()— Computes the intersection of arrays including keys.array_chunk()— Splits an array into chunks.array_pad()— Pads an array to a certain length with a value.array_fill()— Fills an array with values.array_flip()— Swaps all keys with values.array_reverse()— Reverses an array.
5. Array Functions for Aggregation and Summarization
These functions help you summarize or aggregate data from arrays.
array_sum()— Returns the sum of all values in an array.array_product()— Returns the product of all values in an array.array_count_values()— Counts all values in an array.array_unique()— Removes duplicate values from an array.array_map()— Applies a callback function to each element in an array (returns a new array).array_filter()— Filters elements of an array using a callback function.array_reduce()— Reduces an array to a single value using a callback function.
6. Array Functions for Key and Value Manipulation
These functions are used for working with keys and values in arrays.
array_keys()— Returns all keys of an array.array_values()— Returns all values of an array.array_flip()— Exchanges keys and values.array_rand()— Picks one or more random keys from an array.array_key_first()— Returns the first key of an array.array_key_last()— Returns the last key of an array.
7. Array Functions for Array Information and Properties
These functions are used for getting information about the array.
count()— Counts the number of elements in an array.array_length()— Returns the length of an array (similar tocount()).array_is_list()— Checks if the array is a list (numerically indexed).array_chunk()— Splits an array into chunks.array_filter()— Filters elements in the array based on a callback.array_flip()— Flips keys and values in an array.
8. Array Functions for Recursive Operations
These functions work with arrays that may be multidimensional (nested arrays).
array_walk_recursive()— Applies a callback function to each element of an array recursively.array_map()— Can be used recursively if you apply it to multidimensional arrays (via callback).array_filter()— Can be used with a recursive callback if the array is multidimensional.array_merge_recursive()— Merges arrays recursively, handling multidimensional arrays.
9. Other Miscellaneous Array Functions
These functions don’t fit neatly into other categories but are useful for specific tasks.
array_diff_key()— Computes the difference of arrays using keys.array_intersect_key()— Computes the intersection of arrays using keys.array_multisort()— Sorts multiple arrays or multidimensional arrays.array_walk()— Applies a callback to each element of an array.array_rand()— Picks one or more random elements from an array.array_flip()— Swaps keys and values.array_replace()— Replaces elements of an array with values from another array.
No hay comentarios:
Publicar un comentario