PHP array_flip() Function
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);
?>
Try it Yourself »
Definition and Usage
The array_flip() function flips/exchanges all keys with their associated values in an array.
Syntax
array_flip(array)
Parameter Values
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
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.