PHP Array Exercises : Sort an array in reverse order
PHP Array: Exercise-28 with Solution
Write a PHP script to sort an array in reverse order (highest to lowest).
<?php $colors = array("Red", "Orange", "Black", "White"); rsort($colors); print_r($colors); ?>
Array (  => White  => Red  => Orange  => Black )
PHP Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a PHP function to generate a random password (contains uppercase, lowercase, numeric and other) using shuffle() function.
Next: Write a PHP program to generate an array with a range taken from a string.
What is the difficulty level of this exercise?
PHP: Tips of the Day
PHP: Extract numbers from a string
$str = 'In My Cart : 11 12 items'; preg_match_all('!\d+!', $str, $matches); print_r($matches);
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework