PHP array_intersect() Function6 Jan 2025 | 1 min read The array_intersect( ) function is used to Computes the intersection of arrays. It compares two or more arrays and returns an array containing all the values of the first array that are present in other arrays. In this operation, keys are preserved. This function was introduced in PHP 4.0.1. SyntaxParameter
Return TypeIt returns an array containing the entries from array1 that are present in all of the other arrays. EXAMPLE 1Output: Array ( [a] => java [0] => python ) EXAMPLE 2Output: Array ( [a] => chess ) EXAMPLE 3Output: Array ( [Orange] => 100 [Apple] => 200 [Banana] => 300 ) EXAMPLE 4Output: Array ( [2] => rishi [3] => ayush ) Next TopicPhp-array-intersect-key-function |
PHP array_count_values() Function The array_count_values() function returns an array where the keys are the original array's values, and the values is the number of occurrences. In other words, we can say that array_count_values() function is used to calculate the frequency of all of the elements of...
1 min read
PHP array_change_key_case() Function It is an inbuilt function of PHP. The array_change_key_case() function returns an array with all arrays keys in lower case or upper case. Syntax array_change_key_case(array,case); Parameter Description Is compulsory array Specifies the array to use compulsory case Case to use(Upper or Lower) optional Important Note: If the second parameter is avoided then by default the...
1 min read
The array_replace() function is a built-in function in PHP. The PHP array_replace( ) function is used to replace the values of the first array with the values from following arrays. This function was introduced in PHP 5.3.0. Syntax array array_replace ( array $array1 [, array $... ]...
1 min read
The array_reduce() function is a inbuilt function of PHP. The array_reduce( ) function is used to reduce the array to a single value using a callback function. This function was introduced in PHP 4.0.5. Syntax mixed array_reduce ( array $array , callable $callback [, mixed $initial =...
1 min read
The each( ) function is an inbuilt function of PHP. It is used to fetch the key and value of the current element and moves the internal pointer forward. This function was introduced in PHP 4.0. Syntax array each ( array &$array ); Parameter Parameter Description Is compulsory array Specifies the array to...
1 min read
PHP natsort() Function The PHP natsort( ) function is used to sort an array using a "natural order" algorithm. The natsort( ) function implements a sort algorithm but maintains original keys and values. This function was introduced in PHP 4.0. Syntax bool natsort ( array &$array ); Parameter Parameter Description Is compulsory array Specifies...
2 min read
This function is inbuilt in PHP and it was introduced in PHP 5. The function array_diff_uassoc() is used to compute the difference of arrays with additional index check which is performed by a user supplied callback function. In simple words, the function compares array1 against array2...
1 min read
The array_replace_recursive() function is an inbuilt function of PHP. The array_replace_recursive( ) function is used to replace the values from passed arrays into the first array recursively. This function was introduced in PHP 5.3.0. Syntax array array_replace_recursive ( array $array1 [, array $... ] ); Parameter Parameter Description Is compulsory array1 Specifies an...
2 min read
The array_merge_recursive( ) function is a built-in function in PHP. This function is used to merge the elements or values of two or more arrays together into a single array, the values of one are appended to the end of the ious one. This function...
1 min read
The array_search() function is an inbuilt function of PHP. It is used to search the array against the given value. The function returns the first corresponding key if successful. This function was introduced in PHP 4.0.5. Syntax mixed array_search ( mixed $needle , array $haystack [, bool...
1 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India