Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP array_flip() Function

PHP array_flip() Function

PHP Array ReferenceComplete PHP Array Reference Manual

Example

Flip the keys and their associated values in an array:

"red","b"=>"green","c"=>"blue","d"=>"yellow"); $result=array_flip($a1); print_r($result); ?>

Run Example »


Definition and Usage

The array_flip() function is used to reverse/exchange the keys and their associated values in an array.


Syntax

array_flip(

array

);

Parameters Description
array Required. Specifies the array whose key/value pairs are to be flipped.

Technical Details

Return Value: Returns the flipped array on success, or NULL on failure.
PHP Version: 4+

PHP Array ReferenceComplete PHP Array Reference Manual