PHP array_combine() functionThe 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 Functions
|