PHP Basic Tutorial
PHP offers a rich set of built-in functions to work with arrays. Here are some of the commonly used array functions in PHP:
FUNCTION |
DESCRIPTION |
---|---|
Creates an array |
|
Adds one or more elements to the end of an array |
|
Removes and returns the last element of an array |
|
Adds one or more elements to the beginning of an array |
|
Removes and returns the first element of an array |
|
Checks if a specified key exists in the array |
|
Returns all the keys of an array |
|
Returns all the values of an array. |
|
Filters elements of an array using a callback function |
|
Applies a callback function to each element of an array. |
|
Reduces an array to a single value using a callback function |
|
Checks if a value exists in an array |
|
Searches the array for a value and returns its key if found |
|
Sorts an array in ascending order |
|
Sorts an array in descending order |
|
Sorts an array by key in ascending order |
|
Sorts an array by key in descending order |
|
Splits an array into chunks of specified size |
|
Merges two or more arrays |
|
Creates an array by using one array for keys and another for values |
|
Extracts a portion of an array |
|
Removes a portion of an array and replaces it |
|
Counts the number of elements in an array |
|
Returns an array with elements in reverse order |
|
Removes duplicate values from an array |