Example
Flip all keys with their associated values in an array:
<?php
$a1=array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow");
$result=array_flip($a1);
print_r($result);
?>
Run example »
Definition and Usage
The array_flip() function flips/exchanges all keys with their associated values in an array.
Syntax
array_flip(array);
Parameter | Description |
---|---|
array | Required. Specifies an array of key/value pairs to be flipped |
Technical Details
Return Value: | Returns the flipped array on success. NULL on failure |
---|---|
PHP Version: | 4+ |
< PHP Array Reference