Reverse an array without function in php

<?php

$array = array(9,8,7,6,5,4,3,2,1);

$size = count ($array);

$arrau_rev = array();


for($i = $size-1; $i>=0; $i--){

$arrau_rev[] = $array[$i];

}

echo"<pre>";

print_r($arrau_rev);

?>


Output:- 


Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
    [4] => 5
    [5] => 6
    [6] => 7
    [7] => 8
    [8] => 9
)

Comments

Popular posts from this blog

Add Css And Js Files on Specific Page In laravel

Be 10x 10 tools from sessions

Diffrence between Put and Patch