Keys from array become values and values from array become keys.

array:flip(ARRAY $array) : ARRAY

array:flip(['name' => 'foo'])
#=> [ "foo" => "name" ]

array:flip(['name' => 'foo','email' => 'test@example.com'])
#=> [ "foo" => "name", "test@example.com" => "email" ]

# note: array keys are always unique -- cannot have duplicates.
array:flip(['a' => 'foo','b' => 'foo'])
#=> [ "foo" => "b" ]

array:flip([])
#=> []

array:flip([5,10,15])
#=> [ 5 => 0, 10 => 1, 15 => 2 ]

Copyright ©2013-2022 SunSed®. All rights reserved.