Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

Array Functions

PHP Array Functions

PHP provides a set of built-in functions that can be used with arrays.

Function

Description

array()

Generate an array.

array_change_key_case()

Convert all keys in an array to lowercase or uppercase.

array_chunk()

Divides an array into smaller arrays

array_column()

Retrieves the values from a specific column in the input array.

array_combine()

Generates an array using elements from a ‘keys’ array and a ‘values’ array

array_count_values()

Counts all the values in an array.

array_diff()

Compares arrays and returns the differences based on values only.

array_diff_assoc()

Compares arrays and returns the differences based on both keys and values.

array_diff_key()

Compares arrays and returns the differences based on keys only.

array_diff_uassoc()

Compares arrays and returns the differences by evaluating keys only.

array_diff_ukey()

Compares arrays and returns the differences based on keys and values, utilizing a user-defined key comparison function

array_fill()

Populates an array with values.

array_fill_keys()

Populates an array with values while specifying keys

array_filter()

Filters the values of an array using a callback function.

array_flip()

Swaps all keys with their corresponding values in an array.

array_intersect()

Compares arrays and returns the matches based on values only.

array_intersect_assoc()

Compares arrays and returns the matches based on both keys and values

array_intersect_key()

Compares arrays and returns the matches based on keys only.

array_intersect_uassoc()

Compares arrays and returns the matches based on keys and values, using a user-defined key comparison function.

array_intersect_ukey()

Compares arrays and returns the matches based on keys only, using a user-defined key comparison function.

array_key_exists()

Checks whether the specified key is present in the array.

array_keys()

Retrieves all the keys from an array

array_map()

Passes each value of an array to a user-defined function, which returns new values.

array_merge()

Combines one or more arrays into a single array.

array_merge_recursive()

Recursively merges one or more arrays into a single array.

array_multisort()

Sorts multiple or multi-dimensional arrays.

array_pad()

Inserts a specified number of items with a given value into an array.

array_pop()

Removes the last element from an array.

array_product()

Computes the product of the values in an array.

array_push()

Adds one or more elements to the end of an array.

array_rand()

Returns one or more random keys from an array.

array_reduce()

Converts an array to a string using a user-defined function.

array_replace()

Substitutes the values of the first array with values from the subsequent arrays.

array_replace_recursive()

Recursively replaces the values of the first array with values from the subsequent arrays.

array_reverse()

Returns an array in reverse order.

array_search()

Searches an array for a specified value and returns the corresponding key.

array_shift()

Removes the first element from an array and returns the value of the removed element.

array_slice()

Returns specified sections of an array.

array_splice()

Removes and replaces designated elements of an array.

array_sum()

Calculates the sum of the values in an array.

array_udiff()

Compares arrays and returns the differences based on values only, using a user-defined key comparison function.

array_udiff_assoc()

Compares arrays and returns the differences based on keys and values, using a built-in function for key comparison and a user-defined function for value comparison.

array_udiff_uassoc()

Compares arrays and returns the differences based on keys and values, using two user-defined functions for key comparison.

array_uintersect()

Compares arrays and returns the matches based on values only, using a user-defined function for key comparison.

array_uintersect_assoc()

Compares arrays and returns the matches based on both keys and values, using a built-in function for key comparison and a user-defined function for value comparison.

array_uintersect_uassoc()

Compares arrays and returns the matches based on keys and values, using two user-defined functions for key comparison.

array_unique()

Removes duplicate values from an array.

array_unshift()

Adds one or more elements to the start of an array.

array_values()

Retrieves all the values from an array.

array_walk()

Applies a user-defined function to each element of an array.

array_walk_recursive()

Recursively applies a user-defined function to each element of an array.

arsort()

Sorts an associative array in descending order based on the values.

asort()

Sorts an associative array in ascending order based on the values.

compact()

Create an array that includes variables and their corresponding values.

count()

Returns the count of elements in an array.

current()

Returns the current element of an array

each()

Deprecated since PHP 7.2. Returns the current key-value pair from an array.

end()

Sets the internal pointer of an array to its last element

extract()

Imports variables from an array into the current symbol table.

in_array()

Checks whether a specified value is present in an array.

key()

Retrieves a key from an array.

krsort()

Sorts an associative array in descending order based on the keys.

ksort()

Sorts an associative array in ascending order based on the keys.

list()

Assigns variables as though they were elements of an array.

natcasesort()

Sorts an array using a case-insensitive natural order algorithm.

natsort()

Sorts an array using a natural order algorithm.

next()

Moves the internal pointer of an array forward.

pos()

An alias for current().

prev()

Resets the internal array pointer to the beginning.

range()

Creates an array that includes a range of elements.

reset()

Sets the internal pointer of an array to its first element.

rsort()

Sorts an indexed array in descending order.

shuffle()

Randomly shuffles an array.

sizeof()

Alias of count()

sort()

Arranges an indexed array in ascending order.

uasort()

Sorts an array by its values using a user-defined comparison function while preserving the index association.

uksort()

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

usort()

Sorts an array by its values using a custom comparison function.