PHP have some built in functions to manipulate arrays, listing them from database queries and many more stuff. PHP sports both single and multidimension arrays. Following functions are used to do specific things in php.
- array(); This function creates an array and this is in php since php 3.
- array_change_key_case() This function returns lower case array to uppercase array, and uppercase array to lowercase array this function is in php since php 4.
- array_chunks(); This function splits an array into chunks. Means this function will split each element of your array into a chunk and say it. This function is in php since PHP 4.
- arra_combine(); Suppse you are getting Student names in an array, and Their results in another array, you will use this function to combine both arrays, this will use first name array as key and result as value of array. This is helpful function and is in php since php 5.
- array_count_values(); This will return number of values in your array. This function is with php since php 4.
- array_diff(); This function compare the values inside array and return the difference of values in array. Suppose you have 2 values in an array this function can compare them and return result. This is with php since php 4.
- extract(); This is very useful function giving array inside this function will create variables of your keys in that array. This is with php since php 3.
- array_diff_assoc(); This function compares both keys and values and return the difference in keys and values. Since php 4.
- array_diff_key(); Returns key difference of an array. PHP 5.
- array_fill(); This function fills array with values. We provide values and array name as arguments. php 4.
- array_merge(); This function merges one or more arrays into 1 array and you can access values of all arrays from 1. PHP 4.
- array_pop(); This function deletes the last value in array. To delete last value of array we use this function. PHP 4.
- array_push(); This function puts new element in last of array. PHP 4.
- Array_product(); This function returns total of number array values. This will return you sum of values inside array. PHP 4.
- array_rand(); This function returns one or more random values from an array where you can get random values of array. PHP 4.
- array_search(); This function search the given value from array and then returns the key of that value. PHP 4.
- array_sum(); This function returns total sum of numeric values from numeric array. PHP 4.
- array_unique(); This function used to remove duplicate values from an array. To remove duplicate values use this function in argument give array. PHP 4.
- array_values(); Return all values. PHP 4.
- arsort(); Sort index and values of array in reverse. PHP 4.
- asort(); Sort index and values of array. PHP 3.
- count(); Function counts values in array. PHP 4.
There are many more functions about arrays in php but these were important to use so i have listed them here. More details about these functions can be found here.
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?