Php Array functions


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.

Function Descrption
count() The count() function counts the elements of an array or the properties of an object.
list() The list() function is used to assign values to a list of variables in one operation.
include() The include() takes all the text in a specified file and copies it into the file that uses the include function.
in_array() The in_array() function searches an array for a specific value. this function returns true if the value is found in the array, or false otherwise
current() The current() function returns the value of the current element in an array.
next() The next() function moves the internal pointer to, and outputs, the next element in the array.
prev() The prev() function moves the internal pointer to, and outputs, the previous element in the array.
end() The end() function moves the internal pointer to, and outputs, the last element in the array.
each() The each() function returns the current element key and value and moves the internal pointer forward. this element key value is returned in an array with four elements. two elements(1 and value) for the element value, and two elements(0 and key) for the element key,
sort() The sort() function sorts an array by the values. this function assigns new keys for the elements in th array. existing keys will be removed. this function returns true on success, or false on failure.
rsort() The rsort() function sorts an array by the values in reverse order. this function assigns new keys for the elements in th array. existing keys will be removed. this function returns true on success, or false on failure.
asort() The asort() function sorts an array by the values, the values keep their original keys. this function returns true on success, or false on failure.
arsort() The arsort() function sorts an array by the values in reverse order, the values keep their original keys. this function returns true on success, or false on failure.
array_merge() The array_merge() function merge one or more array into one array.
array_reverse() The array_reverse() function returns an array in the reverse order.