Ad

How To Sort An Array By Keys In An Ascending Direction?

- 1 answer

here is the input i am getting from my flash file

process.php?Q2=898&Aa=Grade1&Tim=0%3A0%3A12&Q1=908&Bb=lkj&Q4=jhj&Q3=08&Cc=North%20America&Q0=1

and in php i use this code foreach ($_GET as $field => $label) { $datarray[]=$_GET[$field];

echo  "$field :";
echo $_GET[$field];;
echo "<br>";

i get this out put

Q2 :898 Aa :Grade1 Tim :0:0:12 Q1 :908 Bb :lkj Q4 :jhj Q3 :08 Cc :North America Q0 :1

now my question is how do i sort it alphabaticaly so it should look like this Aa :Grade1 Bb :lkj Cc :North America Q0 :1 Q1 :908

and so on....before i can insert it into the DB

Ad

Answer

ksort($_GET);

This should ksort the $_GET array by it's keys. krsort for reverse order.

Ad
source: stackoverflow.com
Ad