PHP array_flip () function
Examples
Reverse array keys and the corresponding associated key:
<?php
$a1=array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow");
$result=array_flip($a1);
print_r($result);
?>
$a1=array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow");
$result=array_flip($a1);
print_r($result);
?>
Running instance »
Definition and Usage
array_flip () function is used to reverse / exchange key array keys and an association.
grammar
array_flip( array );
参数 | 描述 |
---|---|
array | 必需。规定需进行键/值对反转的数组。 |
technical details
return value: | If successful reverse, inverted array is returned. If the reversal fails, it returns NULL. |
---|---|
PHP version: | 4+ |
Complete PHP Array Reference