⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 language.operators.array.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Array Operators</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="language.operators.string.html">String Operators</a></div> <div class="next" style="text-align: right; float: right;"><a href="language.operators.type.html">Type Operators</a></div> <div class="up"><a href="language.operators.html">Operators</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="language.operators.array" class="sect1">   <h2 class="title">Array Operators</h2>   <table border="5">    <caption><b>Array Operators</b></caption>    <colgroup>     <thead valign="middle">      <tr valign="middle">       <th colspan="1">Example</th>       <th colspan="1">Name</th>       <th colspan="1">Result</th>      </tr>     </thead>     <tbody valign="middle" class="tbody">      <tr valign="middle">       <td colspan="1" rowspan="1" align="left">$a + $b</td>       <td colspan="1" rowspan="1" align="left">Union</td>       <td colspan="1" rowspan="1" align="left">Union of $a and $b.</td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left">$a == $b</td>       <td colspan="1" rowspan="1" align="left">Equality</td>       <td colspan="1" rowspan="1" align="left"><b><tt>TRUE</tt></b> if $a and $b have the same key/value pairs.</td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left">$a === $b</td>       <td colspan="1" rowspan="1" align="left">Identity</td>       <td colspan="1" rowspan="1" align="left"><b><tt>TRUE</tt></b> if $a and $b have the same key/value pairs in the same        order and of the same types.</td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left">$a != $b</td>       <td colspan="1" rowspan="1" align="left">Inequality</td>       <td colspan="1" rowspan="1" align="left"><b><tt>TRUE</tt></b> if $a is not equal to $b.</td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left">$a &lt;&gt; $b</td>       <td colspan="1" rowspan="1" align="left">Inequality</td>       <td colspan="1" rowspan="1" align="left"><b><tt>TRUE</tt></b> if $a is not equal to $b.</td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left">$a !== $b</td>       <td colspan="1" rowspan="1" align="left">Non-identity</td>       <td colspan="1" rowspan="1" align="left"><b><tt>TRUE</tt></b> if $a is not identical to $b.</td>      </tr>     </tbody>    </colgroup>   </table>   <p class="para">    The <i>+</i> operator    appends elements of remaining keys from the right handed array to the     left handed, whereas duplicated keys are NOT overwritten.   </p>   <p class="para">    <div class="informalexample">     <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$a&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">"a"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"apple"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"b"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"banana"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$b&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">"a"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"pear"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"b"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"strawberry"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"c"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"cherry"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$c&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$a&nbsp;</span><span style="color: #007700">+&nbsp;</span><span style="color: #0000BB">$b</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;Union&nbsp;of&nbsp;$a&nbsp;and&nbsp;$b<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"Union&nbsp;of&nbsp;\$a&nbsp;and&nbsp;\$b:&nbsp;\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$c</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$c&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$b&nbsp;</span><span style="color: #007700">+&nbsp;</span><span style="color: #0000BB">$a</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;Union&nbsp;of&nbsp;$b&nbsp;and&nbsp;$a<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"Union&nbsp;of&nbsp;\$b&nbsp;and&nbsp;\$a:&nbsp;\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$c</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>     </div>    </div>    When executed, this script will print the following:    <div class="example-contents"><pre><div class="cdata"><pre>Union of $a and $b:array(3) {  [&quot;a&quot;]=&gt;  string(5) &quot;apple&quot;  [&quot;b&quot;]=&gt;  string(6) &quot;banana&quot;  [&quot;c&quot;]=&gt;  string(6) &quot;cherry&quot;}Union of $b and $a:array(3) {  [&quot;a&quot;]=&gt;  string(4) &quot;pear&quot;  [&quot;b&quot;]=&gt;  string(10) &quot;strawberry&quot;  [&quot;c&quot;]=&gt;  string(6) &quot;cherry&quot;}</pre></div>    </pre></div>   </p>   <p class="para">    Elements of arrays are equal for the comparison if they have the    same key and value.   </p>   <p class="para">    <div class="example">     <p><b>Example #1 Comparing arrays</b></p>     <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$a&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">"apple"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"banana"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$b&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #0000BB">1&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"banana"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"0"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"apple"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$a&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #0000BB">$b</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;bool(true)<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$a&nbsp;</span><span style="color: #007700">===&nbsp;</span><span style="color: #0000BB">$b</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;bool(false)<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>     </div>    </div>   </p>   <p class="para">    See also the manual sections on the     <a href="language.types.array.html" class="link">Array type</a> and     <a href="ref.array.html" class="link">Array functions</a>.   </p>  </div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="language.operators.string.html">String Operators</a></div> <div class="next" style="text-align: right; float: right;"><a href="language.operators.type.html">Type Operators</a></div> <div class="up"><a href="language.operators.html">Operators</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -