Array_flip () returns an inverted array. For example, the key name in trans is changed to a value, and the value in trans is changed to a key name.
Array_flip () returns an inverted array. For example, the key name in trans is changed to a value, and the value in trans is changed to a key name.
Description
Array array_flip (array trans)
Array_flip () returns an inverted array. For example, the key name in trans is changed to a value, and the value in trans is changed to a key name.
Note that the value in trans must be valid key names, for example, integer or string. If the value type is incorrect, a warning will be issued, and the problematic key/value pair will not be reversed.
If the same value appears multiple times, the last key name is used as its value, and all others are lost.
Array_flip () returns FALSE if it fails.
Instance:
The Code is as follows:
$ Hills = array ("first" => "data1", "second" => "data2", "third" => "data1 ″);
$ Hills = array_flip ($ hills); // restore key name
$ Hills1 = array_flip ($ hills); // Delete duplicate
Display $ hills1
The result is:
Data2 data1 data.