|
|
Php Array Elements Function array_flip()
|
Tutorials » Php »
|
Topic |
What is array_flip() Function?
|
|
Explanation |
|
The "array_flip()" function exchanges all keys with their associated values within an array.
Syntax:
array_flip(array)
In the above syntax "array" is the array for which the keys and values must be exchanged.
Example:
<?php
$a=array(0=>"Zero",1=>"One",2=>"Two");
print_r(array_flip($a));
?>
Result:
Array ( [Zero]=> 0 [One]=> 1 [Two]=> 2 )
In the above example array keys 0,1,2 of the array "$a" are exchanged with values Zero,One,Two to display the result.
|
|
A Note |
Learn PHP programming language tutorial with simple and neat example. Hope you enjoy this free tutorial.
Do give us your valuable feedback and suggestions on this online tutorial. This is a Copyright Content.
|
|
|
|