PHP Programing language

array_flip() Functions in PHP
Previous Home Next

array_flip()

The array_flip() function flips/exchanges all keys with their associated values in an array.

Syntax:
array_flip(array);

In above syntax,"array" specifies an array of key/value pairs to be flipped.

Example:

<?php
$array1=array("a"=>"Apple","b"=>"Banana","c"=>"Orange","d"=>"Mango");
$result=array_flip($array1);
print_r($result);
?>

Output:

Array ( [Apple] => a [Banana] => b [Orange] => c [Mango] => d )

Previous Home Next