PHP - Function array_flip()


Advertisements


Syntax

array array_flip ( array $input );

Definition and Usage

array_flip() returns an array in flip order, i.e. keys from input become values and values from input become keys.

If a value has several occurrences, the latest key will be used as its values, and all others will be lost.

Parameters

Sr.No Parameter & Description
1

input

The array to be fliped

Return Values

Returns FALSE if it fails otherwise fliped array.

Example

Try out following example −

<?php
   $array = array("a"=>1, "b"=>2, "c"=>3, "d"=>4, "e"=>5);
   
   print_r(array_flip($array));
?> 

This will produce the following result −

Array ( [1] => a [2] => b [3] => c [4] => d [5] => e )	

php_function_reference.htm

Advertisements