PHP Array combine() Function6 Jan 2025 | 1 min read 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
Important note: Total number of elements in both of the arrays must be equal for the function to execute successfully otherwise, it will throw an error.Example 1Output: Array ( [Php] => 95 [Core java] => 96 [C] => 80 [Javascript] => 75 [C++] => 68 ) Example 2Output: Array ( [Ajay] => 24 [Amit] => 30 [Rahul] => 35 ) Example 3Output: Array ( [a] => Cricket [b] => Football [c] => Badminton [d] => Hockey ) Example 4Output: Array ( [green] => guava [red] => cherry [yellow] => orange ) Next TopicPhp-array-compact-function |
The array_merge( ) function is a built-in function of PHP. This function is used to merge the elements or values of two or more arrays together into a single array. This function was introduced in PHP 4.0. Syntax array array_merge(array $array1[, array $...]); Parameter Parameter Description Is compulsory array1 Specifies an array. compulsory array2 Specifies an...
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
PHP asort() Function The asort( ) function is an inbuilt function of PHP. The asort( ) function is used to sort an associative array in ascending order, according to the value. This function was introduced in PHP 4.0. Syntax bool asort ( array &$array [, int $sort_flags =...
1 min read
The array_arsort( ) function is an inbuilt function of PHP. The array_arsort( ) function is used to sort an array in reverse order and the function maintains index association. This function was introduced in 4.0. Syntax bool arsort ( array &$array [, int $sort_flags = SORT_REGULAR ]...
1 min read
The array_push() function is a inbuilt function in PHP. The array_push() function is used to add one or more elements onto the end of an array. The length of array increases by the number of variables pushed. The array_push() function was introduced in PHP 4.0. Syntax int...
1 min read
The array_splice() function is an extended version of array_slice() function. The array_splice() function removes selected elements from an array and replaces it with new elements. This function was introduced in PHP 4. Syntax arrayarray_splice ( array &$input , int $offset [, int $length = count($input) [, mixed...
1 min read
The array_key_last( ) function is used to get the last key of an array. This function was introduced in PHP 7.3.0 Syntax mixed array_key_last ( array $array ); Parameters Parameter Description Is compulsory array Specifies the array. compulsory Return Values The array_key_last( ) function returns the last key of the array if the array is not...
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
The array_uintersect() is an inbuilt function in PHP. It is used to compute the intersection of two or more arrays depending on the values. The first array values are compared with all the other arrays with the help of an user-defined function, and the matches...
1 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. Syntax array array_fill_keys ( array $keys , mixed...
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