Some Array Functions:-
- array_diff() :-
- The array_diff() function compares the values of two(or more) arrays, and returns the differences.
- This function compares the values of two(or more) arrays, and return an array that contains the entire from array1 that are not present in array2 or array3 etc.
- It can be explained further with a suitable example:-
array_diff().php:-
Screenshot:-
2. array_intersect() :-
- The array_intersect() function compares the values of two(or more) arrays, and returns the matches.
- This function compares the values of two or more arrays, and return an array that contains the entries from array1 that are present in array2, array3 etc.
- Now, explain it with a suitable example:-
array_intersect().php:-
Screenshot:-
3. array_push() ;-
- The array_push() function inserts one or more elements to the end of an array.
- Lets see an example:-
array_push().php :-
Screenshot:-
4. array_pop() :-
- The array_pop() function deletes the last element of an array.
- Let consider an example:-
array_pop().php:-
Screenshot:-
5. array_unique() ;-
- The array_unique() function removes duplicate values from an array.
- If two or more array values are the same, the first appearance will be kept and the other will be removed.
- The returned array will keep the first array item's key type.
- Consider an example:-
array_unique().php:-
Screenshot:-
6. array_count():-
- The array_count() function returns the number of elements in an array.
- Consider an example:-
array_count().php:-
Screenshot:-
7. array_merge() ;-
- The array_merge() function merges one or more arrays into one array.
- We can assign one array to the function, or as many as we like.
- If two or more array elements have the same key, the last one overrides the others.
- Let us consider an example:-
array_merge().php:-