PHP array_diff_key() Function6 Jan 2025 | 1 min read This is an inbuilt function of PHP. This function was introduced in PHP 5.1. The array_diff_key() function compares the keys of two or more arrays, and returns entries from array1 that are not present in array2 or array3, etc. Syntax
Return TypeReturns an array containing the entries from array1 that are not present in any of the other arrays. Example 1Output: Array ( [3]=> Boi ) Example 2Output: Array( [20] => Laxman [30] => Rahul [40] => Ganguly [50] => Yuvi ) Example 3Output: Array ( [b] => Bed ) Example 4Output: Array ( [a1]=> red [c3]=> blue [d4]=> black ) Next TopicPhp-array-diff-uassoc-function |
The array_combine() function is an inbuilt function in PHP. This function is introduced in PHP 5. It is used to create an array by using one array for keys and another for its values. Syntax array_combine(array_keys,array_values); Parameter Description Is compulsory array_keys The keys of the array to be used compulsory array_values The values of the...
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...
1 min read
PHP key() Function The key( ) function returns the element key from the current internal pointer position. This function was introduced in 4.0. Syntax mixed key ( array $array ); Parameter Parameter Description Is compulsory array Specifies the array to use. compulsory Returns The key( ) returns the key of the array element that is currently being...
1 min read
PHP array_unique( ) Function The array_unique( ) function is an inbuilt function of PHP and it is used to remove duplicate values from an array. This function was introduced in 4.0.1 Syntax array array_unique ( array $array [, int $sort_flags = SORT_STRING ] ); Parameters Parameter Description Is compulsory array1 The input array. compulsory sort_flags The optional...
1 min read
The array_sum( ) function is an inbuilt function of PHP. The array_sum( ) function calculates the sum of values in an array and returns the sum of values in an array as an integer or float. This function was introduced in PHP 4.0.4. Syntax number array_sum (...
1 min read
The array_diff_assoc() function is used to compare an array against another array and returns the difference. In other words, we can say that array_diff_assoc() function compares the keys and values of two or more arrays and return an array that contains the entries from array1...
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_keys() function is used to get all the keys or a subset of the keys of an array. It returns the keys, numeric and string, from the input array. This function was introduced in PHP 4.0. Syntax array_keys(array1,value,strict); Parameter Parameter Description Is compulsory array Specifies an array. compulsory search_value Specify a value, then only the...
1 min read
The array_walk( ) function is an inbuilt function of PHP. It is used to apply a user supplied function to every element of an array. This function was introduced in 4.0. Syntax bool array_walk ( array &$array , callable $callback [, mixed $userdata = NULL ] ); Parameters Parameter Description Is...
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
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