PHP Array

23 functions

countcount(array $array): int

Counts all elements in an array.

array_pusharray_push(array &$array, mixed ...$values): int

Pushes one or more elements onto the end of array.

array_poparray_pop(array &$array): mixed

Pops the element off the end of array.

array_shiftarray_shift(array &$array): mixed

Shifts an element off the beginning of array.

array_unshiftarray_unshift(array &$array, mixed ...$values): int

Prepends one or more elements to the front of an array.

array_mergearray_merge(array ...$arrays): array

Merges one or more arrays together.

array_slicearray_slice(array $array, int $offset, ?int $length): array

Extracts a slice of the array.

array_searcharray_search(mixed $needle, array $haystack): int|string|false

Searches the array for a given value and returns the key if successful.

in_arrayin_array(mixed $needle, array $haystack): bool

Checks if a value exists in an array.

array_key_existsarray_key_exists(string|int $key, array $array): bool

Checks if the given key exists in the array.

array_keysarray_keys(array $array): array

Returns all the keys of an array.

array_valuesarray_values(array $array): array

Returns all the values of an array.

array_uniquearray_unique(array $array): array

Removes duplicate values from an array.

array_reversearray_reverse(array $array): array

Returns an array with elements in reverse order.

sortsort(array &$array): true

Sorts an array in ascending order.

usortusort(array &$array, callable $callback): true

Sorts an array by values using a user-defined comparison function.

array_maparray_map(?callable $callback, array $array): array

Applies the callback to the elements of the given array.

array_filterarray_filter(array $array, ?callable $callback): array

Filters elements of an array using a callback function.

array_reducearray_reduce(array $array, callable $callback, mixed $initial): mixed

Iteratively reduces the array to a single value using a callback function.

array_columnarray_column(array $array, int|string|null $column): array

Returns the values from a single column in the input array.

array_chunkarray_chunk(array $array, int $length): array

Splits an array into chunks.

array_combinearray_combine(array $keys, array $values): array

Creates an array by using one array for keys and another for its values.

array_fliparray_flip(array $array): array

Exchanges all keys with their associated values in an array.