Dec 06, 2013, by admin
If you want interchange the keys and values of an associative array. It’s very easy, just use PHP’s array_flip() function which perform a very specialized task. It reverses the key-value relationship for all the elements of an associative array and returning a new array that is the mirror image of the original.
Example:
Output:
Exchanged keys and values
(“black” => “white”, “night” => “day”, “close” => “open”)