Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 2590

php-manual-en-7.2.11-1.mga7.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Gets the first key of an array</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.array-key-exists.html">array_key_exists</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.array-key-last.html">array_key_last</a></div>
 <div class="up"><a href="ref.array.html">Array Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.array-key-first" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">array_key_first</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.3.0)</p><p class="refpurpose"><span class="refname">array_key_first</span> &mdash; <span class="dc-title">Gets the first key of an array</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.array-key-first-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><strong>array_key_first</strong></span>
    ( <span class="methodparam"><span class="type">array</span> <code class="parameter">$array</code></span>
   )</div>

  <p class="para rdfs-comment">
   Get the first key of the given <code class="parameter">array</code> without affecting
   the internal array pointer.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.array-key-first-parameters">
  <h3 class="title">Parameters</h3>
  <dl>

   
    <dt>
<code class="parameter">array</code></dt>

    <dd>

     <p class="para">
      An array.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.array-key-first-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns the first key of <code class="parameter">array</code> if the array is not empty;
   <strong><code>NULL</code></strong> otherwise.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.array-key-first-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-6169">
    <p><strong>Example #1 Basic <span class="function"><strong>array_key_first()</strong></span> Usage</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$array&nbsp;</span><span style="color: #007700">=&nbsp;[</span><span style="color: #DD0000">'a'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'b'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'c'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">3</span><span style="color: #007700">];<br /><br /></span><span style="color: #0000BB">$firstKey&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">array_key_first</span><span style="color: #007700">(</span><span style="color: #0000BB">$array</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">firstKey</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
string(1) &quot;a&quot;
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.array-key-first-seealso">
  <h3 class="title">See Also</h3>
  <ul class="simplelist">
   <li class="member"><span class="function"><a href="function.array-key-last.html" class="function" rel="rdfs-seeAlso">array_key_last()</a> - Gets the last key of an array</span></li>
   <li class="member"><span class="function"><a href="function.reset.html" class="function" rel="rdfs-seeAlso">reset()</a> - Set the internal pointer of an array to its first element</span></li>
  </ul>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.array-key-exists.html">array_key_exists</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.array-key-last.html">array_key_last</a></div>
 <div class="up"><a href="ref.array.html">Array Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>