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

PHP中的数组Array

<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>定义数组array&#xff08;&#xff09;</p>
<p>在数组array中用逗号分隔的键&#xff08;key&#xff09; &#61;> 值&#xff08;value&#xff09;</p>
<pre><code>array(
    key &#61;> value,
    key2 &#61;> value2,
    key3 &#61;> value3,
)

</code></pre>
<p>使用短数组语法[]替代array()</p>
<pre><code><? php
$array &#61; array(
&#34;key1&#34; &#61;> &#34;v1&#34;;
&#34;key2&#34; &#61;> &#34;v2&#34;;
&#34;key3&#34; &#61;> &#34;v3&#34;;
)
?>

//短数组语法
$array &#61; [
&#34;key1&#34; &#61;> &#34;v1&#34;;
&#34;key2&#34; &#61;> &#34;v2&#34;;
&#34;key3&#34; &#61;> &#34;v3&#34;;   
]

//没有键名的索引数组
$array &#61; array(&#34;foo&#34;,&#34;bar&#34;,&#34;hello&#34;,&#34;world&#34;);
</code></pre>
<p></p>
                </div>
      </div>
      <div id="treeSkill"></div>
页: [1]
查看完整版本: PHP中的数组Array