Array flip and reverse in php

Array flip and reverse in php

array_flip function is quite useful when you only want to shift array index as array value and vice-verse. On the other hand, if you want to change only array index in descending/reverse order then array_reverse function works great.

Array flip convert key in to index and index in to key.

$a = array (0 => "a", 1 => "b", 2=>"c");
print_r (array_flip ($a));

// Output:  
// Array ( [a] => 0 [b] => 1 [c] => 2 )

Array reverse function changes the order of array value.

$a = array (0 => "a", 1 => "b", 2=>"c");
print_r (array_reverse ($a));
// Output 
// Array ( [0] => c [1] => b [2] => a )

Was this information useful? What other tips would you like to read about in the future? Share your comments, feedback and experiences with us by commenting below!

Total 0 Votes
0

Tell us how can we improve this post?

+ = Verify Human or Spambot ?

Leave a Comment

Back To Top
Cool Ajax - Web Development Tutorial Blog
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.