Here, the cluster is an info exhibit. The capacity will restore another exhibit by flipping keys as qualities and qualities as keys.
As we probably are aware, a cluster contains exceptional keys. In the event that we flip the cluster and the qualities are normal,
at that point, the last worth will be considered as key and its key will be considered as worth.
Examples:
Input:
$arr = array("name" => "Prem", "age" => 28,"city" => "Gwalior");
Function calling:
array_flip($arr);
Output:
Array
(
[Prem] => name
[28] => age
[Gwalior] => city
)
PHP code 1: Example with unique values
<?php
// input array
$arr = array("name" => "Prem", "age" => 28,"city" => "Gwalior");
// flipping array
$temp = array_flip($arr);
print_r ($temp);
?>
Output
Array
(
[Prem] => name
[28] => age
[Gwalior] => city
)
PHP code 2: Example without unique values
<?php
// persons array
$arr = array("a" => "Hello", "b" => "Hello", "c" => "Hi");
// flipping array
$temp = array_flip($arr);
print_r ($temp);
?>
Output
Array
(
[Hello] => b
[Hi] => c
)