Home  >  Article  >  php教程  >  PHP函数Ksort()通过关键字对数组进行排序的具体方式介绍

PHP函数Ksort()通过关键字对数组进行排序的具体方式介绍

WBOY
WBOYOriginal
2016-06-13 11:06:44763browse

我们在学习Listing C的具体代码如下:

<ol class="dp-xml">
<li class="alt"><span><strong><font color="#006699"><span class="tag"></span><span class="tag-name">php</span></font></strong><span> </span></span></li>
<li class="alt"><span><span>$</span><span class="attribute"><font color="#ff0000">data</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">array</font></span><span>("US" =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> "United States", <br>"IN" =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> "India", "DE" =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> "Germany", "ES" =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> <br>"Spain");ksort($data); print_r($data);  </span></span></li>
<li class="">
<span></span><span class="tag"><strong><font color="#006699">?></font></strong></span><span> </span>
</li>
</ol>

它的输出结果如下:

Array ([DE] => Germany

[ES] => Spain

[IN] => India

[US] => United States

)

通过上面例子的介绍,希望大家能清楚PHP函数Ksort()的具体使用。


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn