In this post we explain you How to Combine Two Arrays – One for Key and Another for Value in PHP. For do this PHP has predefined array function array_combine(). Using this function combined array is return.
Combine Two Arrays – One for Key and Another for Value
Syntax: array_combine ( array $keys , array $values )
First array parameter $keys has array of keys and second array parameter array of values.
Output of above example is like that:
Note: If the array of element of both are not equal than its return FALSE result.
Using this array function you can combine two arrays by using one array for keys and other one for its values. If you like this post, Please share this with your friends. Thanks