0
PHP Array Functions
Posted by jujur
on
5:44 AM
PHP Array Functions
PHP Array Introduction
The array functions allow you to
manipulate arrays.PHP supports both simple and multi-dimensional arrays. There are also specific functions for populating arrays from database queries.
Installation
The array functions are part of
the PHP core. There is no installation needed to use these functions.
PHP Array Functions
PHP: indicates the earliest version of PHP
that supports the function.
Function
|
Description
|
PHP
|
Creates an array
|
3
|
|
Returns an array with all keys in lowercase or uppercase
|
4
|
|
Splits an array into chunks of arrays
|
4
|
|
Creates an array by using one array for keys and another for its
values
|
5
|
|
Returns an array with the number of occurrences for each value
|
4
|
|
Compares array values, and returns the differences
|
4
|
|
Compares array keys and values, and returns the differences
|
4
|
|
Compares array keys, and returns the differences
|
5
|
|
Compares array keys and values, with an additional user-made
function check, and returns the differences
|
5
|
|
Compares array keys, with an additional user-made function
check, and returns the differences
|
5
|
|
Fills an array with values
|
4
|
|
Filters elements of an array using a user-made function
|
4
|
|
Exchanges all keys with their associated values in an array
|
4
|
|
Compares array values, and returns the matches
|
4
|
|
Compares array keys and values, and returns the matches
|
4
|
|
Compares array keys, and returns the matches
|
5
|
|
Compares array keys and values, with an additional user-made
function check, and returns the matches
|
5
|
|
Compares array keys, with an additional user-made function
check, and returns the matches
|
5
|
|
Checks if the specified key exists in the array
|
4
|
|
Returns all the keys of an array
|
4
|
|
Sends each value of an array to a user-made function, which returns
new values
|
4
|
|
Merges one or more arrays into one array
|
4
|
|
Merges one or more arrays into one array
|
4
|
|
Sorts multiple or multi-dimensional arrays
|
4
|
|
Inserts a specified number of items, with a specified value, to
an array
|
4
|
|
Deletes the last element of an array
|
4
|
|
Calculates the product of the values in an array
|
5
|
|
Inserts one or more elements to the end of an array
|
4
|
|
Returns one or more random keys from an array
|
4
|
|
Returns an array as a string, using a user-defined function
|
4
|
|
Returns an array in the reverse order
|
4
|
|
Searches an array for a given value and returns the key
|
4
|
|
Removes the first element from an array, and returns the value
of the removed element
|
4
|
|
Returns selected parts of an array
|
4
|
|
Removes and replaces specified elements of an array
|
4
|
|
Returns the sum of the values in an array
|
4
|
|
Compares array values in a user-made function and returns an
array
|
5
|
|
Compares array keys, and compares array values in a user-made
function, and returns an array
|
5
|
|
Compares array keys and array values in user-made functions, and
returns an array
|
5
|
|
Compares array values in a user-made function and returns an
array
|
5
|
|
Compares array keys, and compares array values in a user-made
function, and returns an array
|
5
|
|
Compares array keys and array values in user-made functions, and
returns an array
|
5
|
|
Removes duplicate values from an array
|
4
|
|
Adds one or more elements to the beginning of an array
|
4
|
|
Returns all the values of an array
|
4
|
|
Applies a user function to every member of an array
|
3
|
|
Applies a user function recursively to every member of an array
|
5
|
|
Sorts an array in reverse order and maintain index association
|
3
|
|
Sorts an array and maintain index association
|
3
|
|
Create array containing variables and their values
|
4
|
|
Counts elements in an array, or properties in an object
|
3
|
|
Returns the current element in an array
|
3
|
|
Returns the current key and value pair from an array
|
3
|
|
Sets the internal pointer of an array to its last element
|
3
|
|
Imports variables into the current symbol table from an array
|
3
|
|
Checks if a specified value exists in an array
|
4
|
|
Fetches a key from an array
|
3
|
|
Sorts an array by key in reverse order
|
3
|
|
Sorts an array by key
|
3
|
|
Assigns variables as if they were an array
|
3
|
|
Sorts an array using a case insensitive "natural
order" algorithm
|
4
|
|
Sorts an array using a "natural order" algorithm
|
4
|
|
Advance the internal array pointer of an array
|
3
|
|
Alias of current()
|
3
|
|
Rewinds the internal array pointer
|
3
|
|
Creates an array containing a range of elements
|
3
|
|
Sets the internal pointer of an array to its first element
|
3
|
|
Sorts an array in reverse order
|
3
|
|
Shuffles an array
|
3
|
|
Alias of count()
|
3
|
|
Sorts an array
|
3
|
|
Sorts an array with a user-defined function and maintain index
association
|
3
|
|
Sorts an array by keys using a user-defined function
|
3
|
|
Sorts an array by values using a user-defined function
|
3
|
PHP Array Constants
PHP: indicates the earliest version of PHP
that supports the constant.
Constant
|
Description
|
PHP
|
CASE_LOWER
|
Used with array_change_key_case() to convert array keys to lower
case
|
|
CASE_UPPER
|
Used with array_change_key_case() to convert array keys to upper
case
|
|
SORT_ASC
|
Used with array_multisort() to sort in ascending order
|
|
SORT_DESC
|
Used with array_multisort() to sort in descending order
|
|
SORT_REGULAR
|
Used to compare items normally
|
|
SORT_NUMERIC
|
Used to compare items numerically
|
|
SORT_STRING
|
Used to compare items as strings
|
|
SORT_LOCALE_STRING
|
Used to compare items as strings, based on the current locale
|
4
|
COUNT_NORMAL
|
|
|
COUNT_RECURSIVE
|
|
|
EXTR_OVERWRITE
|
|
|
EXTR_SKIP
|
|
|
EXTR_PREFIX_SAME
|
|
|
EXTR_PREFIX_ALL
|
|
|
EXTR_PREFIX_INVALID
|
|
|
EXTR_PREFIX_IF_EXISTS
|
|
|
EXTR_IF_EXISTS
|
|
|
EXTR_REFS
|
|
|