0

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

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 to start working on your dream project - codefixup@gmail.com

Leave a Reply

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