Ten PHP Array functions that beginners should know

There are many array functions in PHP and most of the beginners don’t know those functions. And because of this absence of knowledge developers write the code to achieve required output. Instead if you knew key array functions then it makes your work easier, saves time and lines of code.

This is list of some of the main key PHP array functions.

1. explode() Split a string by string Returns an array of strings, each of which is a substring of string formed by splitting it on boundaries formed by the string delimiter.

2. list() Assign variables as if they were an array

3. extract() Import variables into the current symbol table from an array

4. end() advances array’s internal pointer to the last element, and returns its value.

5. array_values() returns all the values from the array and indexes the array numerically.

6. Implode() Join array elements with a string

7. array_murge() Merge one or more arrays

8. array_sum()  Calculate the sum of values in an array

9. array_search()  Searches the array for a given value and returns the corresponding key if successful

10. array_walk_recursive()  Apply a user function recursively to every member of an array. Applies the user-defined callbackfunction to each element of the array. This function will recurse into deeper arrays.

There are still many array functions. You can get all functions and their usage on http://php.net

Leave a Reply

Your email address will not be published. Required fields are marked *