PHP Array


array array([mixed ...])

Creates an array using the parameters as elements in the array. By using the => operator, you can specify specific indexes for any elements; if no indexes are given, the elements are assigned indexes starting from 0 and incrementing by one. The internal pointer (see current, reset, and next) is set to the first element.
$array = array("first", 3 => "second", "third", "fourth" => 4);
Note: array is actually a language construct, used to denote literal arrays, but its usage is similar to that of a function, so it's included here.

array array_count_values(array array)

Returns an array whose elements' keys are the input array's values. The value of each key is the number of times that key appears in the input array as a value.

array array_diff(array array1, array array2[, ... array arrayN])

Returns an array containing all of the values from the first array that are not present in any of the other arrays. The keys of the values are preserved.

array array_filter(array array, mixed callback)

Creates an array containing all values from the original array for which the given callback function returns true. If the input array is an associative array, the keys are preserved. For example:
function isBig($inValue) {
  return($inValue > 10);
$array = array(7, 8, 9, 10, 11, 12, 13, 14);
$new_array  = array_filter($array, "isBig"); // contains (11, 12, 13, 14)

array array_flip(array array)

Returns an array in which the elements' keys are the original array's values, and vice versa. If multiple values are found, the last one encountered is retained. If any of the values in the original array are any type except strings and integers, array_flip( ) returns false.

array array_intersect(array array1, array array2[, ... array arrayN])

Returns an array whose elements are those from the first array that also exist in every other array.

array array_keys(array array[, mixed value])

Returns an array containing all of the keys in the given array. If the second parameter is provided, only keys whose values match value are returned in the array.

array array_map(mixed callback, array array1[, ... array arrayN])

Creates an array by applying the callback function referenced in the first parameter to the remaining parameters; the callback function should take as parameters a number of values equal to the number of arrays passed into array_map( ). For example:
function multiply($inOne, $inTwo) {
  return $inOne * $inTwo;
$first = (1, 2, 3, 4);
$second = (10, 9, 8, 7);
$array = array_map("multiply", $first, $second); // contains (10, 18, 24, 28)

array array_merge(array array1, array array2[, ... array arrayN])

Returns an array created by appending the elements of every array to the previous. If any array has a value with the same string key, the last value encountered for the key is returned in the array; any elements with identical numeric keys are inserted into the resulting array.

array array_merge_recursive(array array1, array array2[, ... array arrayN])

Like array_merge( ), creates and returns an array by appending each input array to the previous. Unlike that function, when multiple elements have the same string key, an array containing each value is inserted into the resulting array.

bool array_multisort(array array1[, SORT_ASC|SORT_DESC
                     [, array array2[, SORT_ASC|SORT_DESC
                     [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]], ...])

Used to sort several arrays simultaneously, or to sort a multidimensional array in one or more dimensions. The input arrays are treated as columns in a table to be sorted by rows—the first array is the primary sort. Any values that compare the same according to that sort are sorted by the next input array, and so on.
The first argument is an array; following that, each argument may be an array or one of the following order flags (the order flags are used to change the default order of the sort):
SORT_ASC (default)
Sort in ascending order
Sort in descending order
After that, a sorting type from the following list can be specified:
SORT_REGULAR (default)
Compare items normally
Compare items numerically
Compare items as strings
The sorting flags apply only to the immediately preceding array, and they revert to SORT_ASC and SORT_REGULAR before each new array argument.
This function returns true if the operation was successful and false if not.

array array_pad(array input, int size[, mixed padding])