How to Combine Two Arrays – One for Key and Another for Value in PHP

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.

Code Example:

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

Recommended Posts For You

About Harish

I am professional web developer and blogger. Use this blog to share own api and other web development experience with you. I do accept paid work. Write to me at - [email protected]

View all posts by Harish

Leave a Comment

Your email address will not be published. Required fields are marked *