php

How to Reverse an Array in PHP

In this tutorial, we are going to see how to reverse an array in PHP. You can use PHP’s array_reverse() function to reverse an array.
 

How to Reverse an Array in PHP
<?php
	$langages = array("PHP", "Java", "Python", "HTML");
	 
	// Print the reversed array
	print_r(array_reverse($langages));
?>

Output:

Array ( [0] => HTML [1] => Python [2] => Java [3] => PHP )
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *