• PHP Video Tutorials

PHP - Function array_flip()



Syntax

array array_flip ( array $input );

Definition and Usage

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

Parameters

Sr.No Parameter & Description
1

input

The array to be fliped

Return Values

It returns FALSE if it fails otherwise fliped array.

Example

Try out following example −

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

This will produce the following result −

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