Reversing an Array Using array_reverse() : array_reverse « Data Structure « PHP






Reversing an Array Using array_reverse()

 
<?php 
    $dogs = array('A' => 'C', 'B' => 'D', 'X' => 'Z', 'Q' => 'T'); 
    
    array_reverse($dogs); 
    printf("<pre>%s</pre>\n", var_export($dogs, TRUE)); 
    
    
    $nums = array(5, 2.2, -4, 2.3, 10); 
    array_reverse($nums); 
    printf("<pre>%s</pre>\n", var_export($nums, TRUE)); 
?>
  
  








Related examples in the same category

1.Concisely reversing a string by word
2.Return an array with elements in reverse order
3.array_reverse() function reverses the order of the array elements.
4.Reversing a string by word