Home > php教程 > php手册 > body text

PHP自然语言排序的特点介绍

WBOY
Release: 2016-06-13 11:06:45
Original
1558 people have browsed it

我们通过对Listing G就是一个PHP自然语言排序的例子:

<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>("book-1", "book-10", "book-100", <br>"book-5"); sort($data);print_r($data);  </span></span></li>
<li class="">
<span>natsort($data); print_r($data);</span><span class="tag"><strong><font color="#006699">?></font></strong></span><span> </span>
</li>
</ol>
Copy after login

它的输出结果如下:

Array ([0] => book-1

[1] => book-10

[2] => book-100

[3] => book-5

)

Array

(

[0] => book-1

[3] => book-5

[1] => book-10

[2] => book-100

)

它们的不同已经很清楚了:第二个排序结果更直观,更“人性化”,然而第一个则更符合算法规则,更具“计算机”特点。这就是PHP自然语言排序。


source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template