PHP array_flip() Function


Complete PHP Array Reference

Definition and Usage

The array_flip() function returns an array with all the original keys as values, and all original values as keys.

Syntax

array_flip(array)

Parameter Description
array Required. Specifies an array


Example

<?php
$a=array(0=>"Dog",1=>"Cat",2=>"Horse");

print_r(array_flip($a));
?>

The output of the code above will be:

Array ( [Dog] => 0 [Cat] => 1 [Horse] => 2 )


Complete PHP Array Reference
Have Any Suggestion? We Are Waiting To Hear from YOU!

Your Query was successfully sent!