PHP array_fill_keys() Function6 Jan 2025 | 2 min read The array_fill_keys( ) function is a built-in function in PHP. It is used to create a new array filled with the given keys and value provided as an array to the function. It was introduced in PHP version 5.2. SyntaxParameter
Return TypeIt returns the filled array. EXAMPLE 1Output: Array ( [a] => javatpoint [b] => javatpoint [c] => javatpoint [d] => javatpoint ) EXAMPLE 2Output: Array ( [1] => 1000 [2] => 1000 [3] => 1000 [4] => 1000 [5] => 1000 [apple] => 1000 ) EXAMPLE 3Output: Array ( [Delhi] => lndia [Haryana] => lndia [Bihar] => lndia [Gujarat] => lndia ) EXAMPLE 4Output: Array ( [Delhi] => Array ( [0] => india [1] => javatpoint ) [Haryana] => Array ( [0] => india [1] => javatpoint ) [Bihar] => Array ( [0] => india [1] => javatpoint ) [Gujarat] => Array ( [0] => india [1] => javatpoint ) ) Next TopicPhp-array-filter-function |
The array_intersect_assoc() is used to create an array containing keys and values of the first array whose values (i.e., from the first array) are present in all other arrays, while the index of values is same for all the given arrays. This function was introduced...
1 min read
The array_intersect_ukey( ) function Computes the intersection of arrays using a callback function on the keys for comparison. The function returns an array containing all the values of the first array which have matching keys that are present in all the arguments. This function was...
1 min read
PHP array diff_ukey() Function The array_diff_ukey() is an inbuilt function in PHP. The array_diff_ukey() function compares the keys of two or more arrays with a user-defined function, and returns an array that contains the entries from array1 that are not present in array2 or array3, etc. This...
2 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
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
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
PHP range() Function The PHP range( ) function is used to create an array containing a range of elements. The PHP range( ) function returns an array of elements from low to high. This function was introduced in PHP 4.0. Syntax array range ( mixed $start , mixed...
1 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
PHP krsort() Function The PHP krsort( ) function is used to sort the array elements by the key in descending order. It is mainly used in the associative array. This function was introduced in PHP 4.0. Syntax bool krsort ( array &$array [, int $sort_flags = SORT_REGULAR ]...
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
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