php array functions | php array length | php array add

PHP Array Introduction

The array functions allows you to access and manipulate arrays.
Simple and multi-dimensional arrays are supported.

Installation

Array functions are part of the PHP core. There is no installation needed to uses these functions.

PHP 5 Array Functions 

FunctionDescription
array()Creates an array
array_change_key_case()Change  all keys in an array to lowercase or uppercase
array_chunk()Splits an array into chunks of arrays
array_column()Returns the value  from a single column in the input array
array_combine()Create  an array by using the element  from one "key" array and one "value"
array_count_values()Counts all the values of an array
array_diff()Compare arrays, and return  the differences (compare values only)
array_diff_assoc()Compare arrays, and return  the differences (compare keys and values)
array_diff_key()Compare arrays, and return  the differences (compare keys only)
array_diff_uassoc()Compare arrays, and return  the differences (compare keys and values, using a user-defined key comparison function)
array_diff_ukey()Compare arrays, and return  the differences (compare keys only, using a user-defined key comparison function)
array_fill()Fills an array with values
array_fill_keys()Fill  an array with values, specifying keys
array_filter()Filter  the values of an array using a callback function
array_flip()Flips/Exchanges all the keys with their associated values in an array
array_intersect()Compare arrays, and return  the matches (compare values only)
array_intersect_assoc()Compare arrays and return  the matches (compare keys and values)
array_intersect_key()Compare arrays, and return  the matches (compare keys only)
array_intersect_uassoc()Compare arrays, and return  the matches (compare keys and values, using a user-defined key comparison function)
array_intersect_ukey()Compare arrays, and return  the matches (compare keys only, using a user-defined key comparison function)
array_key_exists()Checks if the specified key exist  in the array
array_keys()Returns all the keys of an array
array_map()Send  each value of an array to a user-made function, which returns new values
array_merge()Merges one or more arrays into a array
array_merge_recursive()Merges one or more arrays into one array recursive manner
array_multisort()Sorts of multiple or multi-dimensional arrays
array_pad()Inserts a specified number of items, with a specified values, to an array
array_pop()Deletes the last element of an array
array_product()To calculates the product of the values in an array
array_push()Inserts  one or more element  to the end of an array
array_rand()Returns one or more random keys from array
array_reduce()Return an array as a string, using a user-defined  function
array_replace()Replaces  the values of the first array with the values from the following array
array_replace_recursive()Replace  the values of the first array with the values from following arrays recursively
array_reverse()Returns an array in the reverse order
array_search()Search  an array for a given value and returns the key
array_shift()Remove  the first element from an array, and returns the value of the removed element
array_slice()Returns selected parts of an array
array_splice()Remove  and replaces specified elements of an array
array_sum()Return  the sum of the values in an array
array_udiff()Compare arrays, and returns the differences (compare values only, using a user-defined keys comparison function)
array_udiff_assoc()Compare arrays, and return  the differences (compare keys and values, using a built-in function to compare the keys and a user-defined function to compare the values)
array_udiff_uassoc()Compares arrays, and return  the differences (compare keys and values, using two user-defined key comparison functions)
array_uintersect()Compare arrays, and return  the matches (compare values only, using a user-defined key comparison function)
array_uintersect_assoc()Compare arrays, and returns the matches (compares keys and values, using a built-in function to compare the keys and a user-defined function to compare the values)
array_uintersect_uassoc()Compare arrays, and return  the matches (compare keys and values, using two user-defined key comparison function)
array_unique()Removes duplicate values from an array
array_unshift()Add  one or more elements to the beginning of the array
array_values()Returns all the values of an array
array_walk()Applies  users function to every member of an array
array_walk_recursive()Applies  users function recursively to every member of an array
arsort()Sorts an associative array descending order, according to the values
asort()Sorts an associative array ascending order, according to the values
compact()Create an array containing variables and their value
count()Return  the number of the element  of an array
current()Returns the current element in an array
each()Return  the current keys and values pair from an array
end()Set the internal pointers of an array to its last element
extract()Imports variables  into the current symbols table from an array
in_array()Check  if a specified value exists in an array
key()Fetches a key from an array
krsort()Sorts an associative array in descending order, according to the keys
ksort()Sort  an associative array in ascending order, according to the key
list()Assign a variables as if they were an array
natcasesort()Sort   an array using case insensitive (natural orders) algorithms
natsort()Sort an array using (natural orders)  algorithms
next()Advance the internal array pointers of  the array
pos()Alias of current()
prev()Rewinds the internal array pointer
range()Creates an array containing a range of the elements.
reset()Sets  the internal pointers of an array to its first element
rsort()Sorts an indexed array in descending order
shuffle()Shuffles an array
sizeof()Alias of count() array
sort()Sorts an indexed array in ascending order
uasort()Sort  an array by values using a user-defined comparison function
uksort()Sorts  an array by keys using a user-defined comparison functions
usort()Sort  an array using a user-defined comparison function

No comments:

Post a Comment