admin 发表于 2023-2-16 18:55:08

php对数组进行排序 sort

<div id="article_content" class="article_content clearfix">
      <link rel="stylesheet" href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/kdoc_html_views-1a98987dfd.css">
      <link rel="stylesheet" href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/ck_htmledit_views-6e43165c0a.css">
                <div id="content_views" class="htmledit_views">
                  <p>第一种对字符串数组进行排序</p>
<pre><code>$text&#61; array(&#34;apple&#34;,&#34;orange&#34;,&#34;pear&#34;);

sort($text);
print_r($text);</code></pre>
<p>输出的结果<br></p>
<p> 第二种&#xff0c;对数字的数组进行排序&#xff08;升序sort&#xff0c;降序rsort&#xff09;</p>
<pre><code>$text &#61; arrray(8,7,6,2,5,1);

sort($text);

print_r($text);</code></pre>
<p></p>
<p><span style="color:#fe2c24;"> 不能对汉字进行排序</span></p>
                </div>
      </div>
      <div id="treeSkill"></div>
页: [1]
查看完整版本: php对数组进行排序 sort