X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

PHP array_flip() Function

PHP Array Reference PHP Array Reference

Example

Flip all keys with their associated values in an array:

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

Run example »

Definition and Usage

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


Syntax

array_flip(array);

Parameter Description
array Required. Specifies an array of key/value pairs to be flipped

Technical Details

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


PHP Array Reference PHP Array Reference

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook