Mr_Splash
asked on
Sorting array returns 1
Hello,
I'm using the array in the snippet beow.
You'll see that the third item has a lower index than the second. When I try to apply sort() to the array it just returns 1.
How can I sort the array so that they display in numerical index order?
Thanks
I'm using the array in the snippet beow.
You'll see that the third item has a lower index than the second. When I try to apply sort() to the array it just returns 1.
How can I sort the array so that they display in numerical index order?
Thanks
Array (
[1209575532] => Array (
[id] => 1 [title] => News Headline! [date] => 02-05-2008 [text] => Pellentesque id orci.
)
[1217524332] => Array (
[id] => 2 [title] => New News! [date] => 09-08-2008 [text] => Morbi commodo.
)
[1214845932] => Array (
[id] => 3 [title] => Go News! [date] => 06-07-2008 [text] => Quisque condimentum.
)
)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes thats correct, if you had read the documentation of ksort/sort and it's return value
Read http://www.php.net/ksort
Read http://www.php.net/ksort
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
using ksort also returns 1.
print_r($array); = returns the text in my snippet above.
print_r(ksort($array)); = returns 1
Any ideas?