如何按升序键对数组进行排序? [英] How to sort an array by keys in an ascending direction?
问题描述
这是我从我的闪存文件中获得的输入
process.php?Q2=898&Aa=Grade1&Tim=0%3A0%3A12&Q1=908&Bb=lkj&Q4=jhj&Q3=08&Cc=North%20America&Q0=1>
在php中我使用这个代码foreach ($_GET as $field => $label){$datarray[]=$_GET[$field];
echo "$field :";回声 $_GET[$field];;echo "
";
我明白了
第二季度:898Aa :1 级蒂姆:0:0:12第一季度:908BB:lkjQ4 :jhj第三季度 :08抄送:北美Q0 :1
现在我的问题是如何按字母顺序对其进行排序,使其看起来像这样Aa :1 级bb :lkj抄送:北美0:1第一季度:908
等等......在我可以将它插入数据库之前
ksort($_GET);
这应该 ksort $_GET
数组由它的键.krsort 用于逆序.
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
ksort($_GET);
This should ksort the $_GET
array by it's keys. krsort for reverse order.
这篇关于如何按升序键对数组进行排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!