Flip and reverse sounds similar. Don’t mix-up them 🙂 array_flip function is 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=> 2 )
Array reverse function change the order of array value.$a = array (0 => "a", 1 => "b", 2=>"c"); print_r (array_reverse ($a)); //output: Array (  => c  => b  => a )
- Useful Resource:
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!