英[flɪp] 美[flɪp]

vt. Flick, tap; press (switch); flip quickly; swing

vi. Crazy; jerk; twist; Bounce

n. Somersault; Browse; Jump (of the barrel when shooting); Throw lightly

adj.[Spoken] Rude, rash, glib; rash, Reckless

Third person singular: flips Present participle: flipping Past tense: flipped Past participle: flipped Comparative: flipper Superlative: flippest

php array_flip() function syntax

Function: Used to reverse/exchange all key names in the array and their associated key values.

Syntax: array_flip(array);

Parameters:

ParametersDescription
arrayRequired. Specifies the array whose key/value pairs need to be reversed.

Description: Returns a reversed array. If the same value appears multiple times, the last key name will be its value, and all All other key names will be lost. If the data type of the value in the original array is not string or integer, the function will report an error.

php array_flip() function example

<?php
$a = array("class" => "php中文网","name" => "西门","job" => "讲师");
$result=array_flip($a);
print_r($result);
?>

Run instance»

Click the "Run instance" button to view the online instance

Output:

Array ( [php中文网] => class [西门] => name [讲师] => job )
<?php
$a1=array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow");
$result=array_flip($a1);
print_r($result);
?>

Run Instance»

Click the "Run Instance" button to view the online instance

Output:

Array ( [red] => a [green] => b [blue] => c [yellow] => d )