PHP array_flip() Function
Complete PHP Array Reference Manual
Example
Flip the keys and their associated values in an array:
"red","b"=>"green","c"=>"blue","d"=>"yellow"); $result=array_flip($a1); print_r($result); ?>Run Example »
Definition and Usage
The array_flip() function is used to reverse/exchange the keys and their associated values in an array.
Syntax
array_flip(
array
);
| Parameters | Description |
|---|---|
| array | Required. Specifies the array whose key/value pairs are to be flipped. |
Technical Details
| Return Value: | Returns the flipped array on success, or NULL on failure. |
|---|---|
| PHP Version: | 4+ |
Complete PHP Array Reference Manual