Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

PHP Function array_flip()


previous

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.

Paramters

ParameterDescription
inputThe 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 following result:

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

previous Printer Friendly

Advertisements


  

Advertisements