can you sort a key in an array? let say you have
data[a][c]=1; data[a][d]=2; data[c][c][a]=3; data[d][d]=4; I want to sort by using [a] or or [c] etc... Can this be done?
Well... use array_flip() to invert keys and values, sort it, and then use another time array_flip().
How exactly do you want it sorted? Do you want it to look like this:
data[a][c]=1; data[a][d]=2; data[c][c][a]=3; data[d][d]=4; or this: data[a][d]=2; data[a][c]=1; data[c][c][a]=3; data[d][d]=4; or this: data[c][c][a]=3; data[d][d]=4; data[a][c]=1; data[a][d]=2; -sridhar
try ksort()..
After a small verification, don't use my method !! It only works with simple arrays : $myarray["a"] = "value 1"; $myarray["b"] = "value 2"; ...
let me rewrite it:
data[a][e]=1; data[f][j]=2; data[c][g][k]=3; data[d][h][l]=4;
^ ^ ^ | | | these are the key I want
I want it to display data in order of the first key, or second or third. and sort the key reverse then display it
ummm the arrow are mess up the key are the one that is in [] ok?
take a look at this page:
http://www.phpbuilder.com/manual/ref.array.php
lots of info in here about Arrays