I'm a newbie when it comes to PHP and even after some searches, I can't quite figure out the proper way to sort out my array. By sort, I don't mean the values but the array indexes along with their respective values.
I have an average temperature array, that has the hour (0-23) as the array index, and the array values gets added within a loop like so:
$tempAvg[date('H', strtotime($currenttime))] = ($temp / 12);
And this would create an array like this:
[11] 21.07
[12] 20.7
...
[23] 20.8
[0] 21.1
[1] 22.4
[2] 20.6
So what I'd like to do, is sort/arrange the indexes so the array would be like this:
[0] 21.1
[1] 22.4
[2] 20.6
[11] 21.07
[12] 20.7
...
[23] 20.8
The reason I need to do this is so I can later turn it into a JSON format that my chart can read easier. I hope I'm making sense. Any help would be appreciated!