Definition
The array_flip() function flip or exchanges all keys with their associated values in an array, i.e. keys from the array become values and the values from the array become keys.
Syntax
array_flip(array)
Parameters
Parameter | Description |
---|---|
array |
Required. Specifies an array of key/value pairs to be flipped. |
Example
<?php
$ages = array("Mark" => 22, "Jeff" => 32, "Mike" => 28);
$result=array_flip($ages);
print_r($result);