Hello Readers ,
The array_flip() function exchanges all keys with their associated values in an array.
Say we have array array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow"); and we want to interchange key and values of an array .
<!DOCTYPE html>
<html>
<body>
<?php
$a1=array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow");
$result=array_flip($a1);
print_r($result);
?>
</body>
</html>
Output :
Array ( [red] => a [green] => b [blue] => c [yellow] => d )
0 Comment(s)