-2

I have an array like...

Array ( [0] => 'Mon' [1] => 'Sun' [2] => 'Sat' [3] => 'Fri' [4] => 'Thu' [5] => 'Wed' [6] => 'Tue' ) 

I want it as follows...

Array ( [0] => 'Tue' [1] => 'Wed' [2] => 'Thu' [3] => 'Fri' [4] => 'Sat' [5] => 'Sun' [6] => 'Mon' ) 
2
  • array_reverse($array); Commented Jan 22, 2018 at 6:30
  • 2
    Yoy need to try out something and come back with any problem faced. Good luck Commented Jan 22, 2018 at 6:31

2 Answers 2

0

You should use array_reverse()

$arr = array(0 => 'Mon', 1 => 'Sun', '2' => 'Sat', 3 => 'Fri', 4 => 'Thu');
$newArr = array_reverse($arr);
print_r($newArr);

Output:

Array ( [0] => Thu [1] => Fri [2] => Sat [3] => Sun [4] => Mon )
Sign up to request clarification or add additional context in comments.

1 Comment

Greate. Work for me !
0
$a= your array;
$y = array_reverse($a);

$y will return your expected output.Hope this will help you

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.