For this PHP code exercise, create a file named odd_numbers.php
. This file should contain a function named odd_numbers()
which accepts one parameter. The parameter must be an array.
Given an array, odd_numbers()
will return an array containing only the odd numbers from the given array in ascending order. If there are no odd numbers in the given array, odd_numbers()
should return an empty array.
For example, given [3, 2, 1]
, odd_numbers()
should return [1, 3]
.
Note: for this exercise, a number means a whole number or, in PHP terms, an integer value.
Review the PHP Code Exercises documentation for more details on performing code exercises.
Jump on the PHP channel in Slack and ask your fellow students and mentors for a hint.