Arrays are used to store and perform operations on a set of values in as form of simple or multidimensional arrays. Following are few most commonly used functions which are used to manipulate arrays in various ways.
- count : Syntax : count($array, $mode);
- $array : Required, Specifies the array.
- $mode : Optional. Specifies the mode.
0 - Default. Does not count all elements of multidimensional arrays
1 - Counts the array recursively (counts all the elements of multidimensional arrays)
- sort : Syntax : sort($array, $sort_type_flags);
- $array : Required value which specifies the array to be sorted.
- $sort_type_flags : It is used to modify the sorting behavior.
The optional second parameter sort_type_flags may be used to modify the sorting behavior (comparison of array elements/items) using below values:
- SORT_REGULAR - Default - Compare items normally (don't change types)
- SORT_NUMERIC - Compare items numerically
- SORT_STRING - Compare items as strings
- SORT_LOCALE_STRING - Compare items as strings, based on the current locale. It uses the locale, which can be changed using setlocale()
- SORT_NATURAL - Compare items as strings using "natural ordering" like natsort()
- SORT_FLAG_CASE - Can be combined (bitwise OR) with SORT_STRING or SORT_NATURAL to sort strings case-insensitively
- array_keys : Syntax: array_keys($array, $value = NULL, $strict = FALSE);
- $array : Required value which specifies the array to be used.
- $value : Optional, if specified then only the keys which are matching the value will be returned.
- $strict : Optional, if passed true then the type of value specified will also be checked i.e (=== comparison operator will be used).
- array_values : Syntax : array_values($array);
- $array : Required specifying an array to be used.
- array_flip : Syntax : array_flip($array);
- $array : Required specifying the array which needs to be flipped.
- array_combine : Syntax : array_combine($keys, $values);
- $keys : Rquired array of keys to be used.
- $values : Required array of values to be used.
- array_merge : Syntax : array_merge($array1, $array2, $array3...)
- $array1 : Required specifying an array to be used.
- $array2 : Optional specifying an array to be used.
- $array3 : Optional specifying an array to be used.
No comments:
Post a Comment