PHP array_keys() Function6 Jan 2025 | 1 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. SyntaxParameter
Return TypeThe array_keys( ) function returns an array containing the keys. EXAMPLE 1Output: Array ( [0] => virat [1] => sachin [2] => ganguly [3] => rahul ) EXAMPLE 2Output: Array ( [0] => a [1] => b [2] => c ) EXAMPLE 3Output: Array ( [0] => c ) EXAMPLE 4Output: Array ( [0] => 3 ) Next TopicPhp-array-krsort-function |
The array_udiff( ) function is an inbuilt function of PHP. The array_udiff( ) function is used to compute the difference of given arrays by using a callback function for data comparison. This function was introduced in PHP 5.1.0. Syntax array array_udiff ( array $array1 , array $array2...
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_udiff_assoc( ) function is an inbuilt function of PHP. The array_udiff_assoc( ) function use a built-in function to compare the keys and values of two or more arrays, and returns the differences. This function was introduced in PHP 5.0. Syntax array array_udiff_assoc ( array $array1 ,...
1 min read
PHP uasort() Function The PHP uasort( ) function is used to sort an array by its values using a user-defined comparison function. This function was introduced in PHP 4.0. Syntax bool uasort ( array &$array , callable $value_compare_func ); Parameter Parameter Description Is compulsory array Specifies the array to be sorted. compulsory user_defined_function This function is a...
2 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
The array_filter( ) function filters the values of an array using a callback function. This function passes each value of the input array to the callback function. If the callback function returns true, the current value from the input is returned into the result array....
2 min read
PHP ksort() Function The PHP ksort() sorts an associative array in ascending order, according to the key. It is mainly used for an associative array. This function was introduced in PHP 4.0. Syntax bool ksort ( array &$array [, int $sort_flags = SORT_REGULAR ] ); Parameter Parameter Description Is compulsory array Specifies the array...
1 min read
The array_uintersect_uassoc( ) is an inbuilt function of PHP. The array_uintersect_uassoc() function uses two user-defined functions to compare the keys and values of two or more arrays, and returns the matches. This function was introduced in PHP 5.0. Syntax array array_uintersect_uassoc ( array $array1 , array $array2...
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_product() function is inbuilt function of PHP. The array_product() function calculates the product of an array. This function was introduced in PHP 5.1.0. Syntax number array_product ( array $array ); Parameters Parameter Description Required/Optional array Specifies an array. compulsory Return Type The array_product() function returns the product as an integer or float. Example 1 <?php $prime=array(2,3,5,7); print_r(array_product($prime)); ?> Output: 210 Example 2 <?php $even=array(2,6); print_r($even); print_r(array_product($even)); echo "\n"; $odd=array(7,9); print_r($odd); print_r(array_product($odd)); ?> Output: Array ( ...
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