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

php中如何按键的方式对关联数组排序ksort

<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>$arr &#61; array(&#34;b&#34;&#61;>&#34;banana&#34;,&#34;a&#34;&#61;>&#34;apple&#34;,&#34;d&#34;&#61;>&#34;dog&#34;,&#34;c&#34;&#61;>&#34;cat&#34;);

//按键排序数组
ksort($arr);
print_r($arr);</code></pre>
<p></p>
<p><span style="color:#fe2c24;">按照24个字母&#xff0c;从小到大&#xff0c;数字从小到大&#xff0c;取得单词首字母从小到大&#xff08;中文下标无法很好排序&#xff09;</span></p>
<p> </p>
                </div>
      </div>
      <div id="treeSkill"></div>
页: [1]
查看完整版本: php中如何按键的方式对关联数组排序ksort