PHP array_flip() Function

The array_flip() is an inbuilt function of PHP and is used to exchanges all keys with their associated values in an array. array_flip() returns an array in flip order, i.e. keys from array become values and values from array become keys.

array_flip() function returns the flipped array on success and NULL on failure.

Parameters

array: An array of key/value pairs to be flipped.

Example #1 array_flip() example


Output:

Example #2 array_flip() example

Example #3 array_flip() example

 

Reference: https://www.php.net/manual/en/function.array-flip.php

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

Recommended Posts:


Prem Tiwari

An engineer by profession and a passionate blogger by heart. Founder of FreeWebMentor.com (A Programming blog for beginners), Tech Speaker at various forums. A part from this he is an open source enthusiast, WordPress Lover, Blogger, SEO, and Growth Strategic.