I don't like how php sorts their arrays and numbers. Here's an array I have.
$array = array(5, 1000, 100, 8000);
rsort($array); // Sorts from highest to lowest
for ($i = 0; $i < 4; $i++)
{
echo $array[$i];
}
Outcome:
8000
5
1000
100
Is there anyway to sort it this way?
8000
1000
100
5
I'm having troubles doing it.
why is it that php treats everything like a string when it comes to the basic functions?
any way.
it is sorting the numbers by the first place value and then sorting conflicts by the second ect.? wow.
try looking for another sort function or look for extra parameters for that one, i'm sure there are some.
edit:
use
Thanks ryex. That solved everything! PHP really gets at me sometimes.
same. it was designed for an entirely different purpose than c# or ruby. the singular purpose of web design. or at-least it has grown into that purpose. as such it has some rather unexpected behavior when compared with other languages.