To reverse an array in PHP, you can use the array_reverse
function. This function takes an array as its argument and returns a new array with the elements in reverse order.
main.php92 chars4 lines
Output:
main.php75 chars9 lines
Alternatively, you can use the rsort
function. This function sorts an array in reverse order based on its values.
main.php72 chars4 lines
Output:
main.php75 chars9 lines
gistlibby LogSnag