I’m having trouble with the PHP for sorting integers starting from 1 to some value where the sorting is based on a selected integer whose value is between 1 and some value.
Here’s how i’d like the function to look:
function sort_integers($count, $selected_value){
....sort()...?
}
So if the $count=7 and you $selected_value=3, then the sort_integers() function would return this:
3,4,5,6,7,1,2
And if the $count=4 and you $selected_value=2, then the sort_integers() function would return this:
2, 3, 4, 1
I think I need a 3rd variable that increments such that I can do a comparison but my head is starting to hurt thinking about how that would be done. Thoughts?
If I got you right, I would do this:
or using builtin functions:
This assumes you just want to align the values like in your example and there is no given array you want to have sorted (as you did not pass one in and did not mention one).