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 »
The array_flip() function flips/exchanges all keys with their associated values in an array.
array_flip(
array)
Parameter | Description |
---|---|
array | Required. Specifies an array of key/value pairs to be flipped |
Return Value: | Returns the flipped array on success. NULL on failure |
---|---|
PHP Version: | 4+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!