<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.array.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'es',
  ),
  'this' => 
  array (
    0 => 'function.current.php',
    1 => 'current',
    2 => 'Devuelve el elemento actual del array',
  ),
  'up' => 
  array (
    0 => 'ref.array.php',
    1 => 'Funciones de Arrays',
  ),
  'prev' => 
  array (
    0 => 'function.count.php',
    1 => 'count',
  ),
  'next' => 
  array (
    0 => 'function.each.php',
    1 => 'each',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'es',
    'path' => 'reference/array/functions/current.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.current" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">current</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">current</span> &mdash; <span class="dc-title">Devuelve el elemento actual del array</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.current-description">
  <h3 class="title">Descripción</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>current</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.object.php" class="type object">object</a></span></span> <code class="parameter">$array</code></span>): <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div>

  <p class="para rdfs-comment">
   Cada array mantiene un puntero interno, que se inicializa
   cuando se inserta el primer elemento en el array.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.current-parameters">
  <h3 class="title">Parámetros</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">array</code></dt>
     <dd>
      <p class="para">
       El array.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.current-returnvalues">
  <h3 class="title">Valores devueltos</h3>
  <p class="para">
   <span class="function"><strong>current()</strong></span> solo devuelve
   el elemento actual apuntado por el puntero interno del
   array <code class="parameter">array</code>.
   <span class="function"><strong>current()</strong></span> no desplaza el puntero.
   Si el puntero está más allá del último elemento de la lista,
   <span class="function"><strong>current()</strong></span> devuelve <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
  </p>
  <div class="warning"><strong class="warning">Advertencia</strong><p class="simpara">
 Esta función puede retornar <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>, pero también puede retornar un valor equivalente a <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
 Por favor, lea la sección sobre los <a href="language.types.boolean.php" class="link">booleanos</a> para más información.
 Utilice el <a href="language.operators.comparison.php" class="link">operador ===</a>
 para probar el valor de retorno exacto de esta función.
</p></div>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.current-changelog">
  <h3 class="title">Historial de cambios</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Versión</th>
      <th>Descripción</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.1.0</td>
 <td>
  O bien convertir el <span class="type"><a href="language.types.object.php" class="type object">object</a></span> en un <span class="type"><a href="language.types.array.php" class="type array">array</a></span> utilizando <span class="function"><a href="function.get-mangled-object-vars.php" class="function">get_mangled_object_vars()</a></span> primero,
  o utilizar los métodos proporcionados por una clase que implemente <span class="interfacename"><a href="class.iterator.php" class="interfacename">Iterator</a></span>, tal como
  <span class="classname"><a href="class.arrayiterator.php" class="classname">ArrayIterator</a></span>.
 </td>
</tr>

<tr>
 <td>7.4.0</td>
 <td>
  A partir de PHP 7.4.0, las instancias de clases <a href="book.spl.php" class="link">SPL</a> son tratadas como
  objetos vacíos sin propiedades en lugar de llamar al método <span class="interfacename"><a href="class.iterator.php" class="interfacename">Iterator</a></span> con
  el mismo nombre que esta función.
 </td>
</tr>


    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.current-examples">
  <h3 class="title">Ejemplos</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Ejemplo #1 Ejemplo de uso de <span class="function"><strong>current()</strong></span></strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$mode </span><span style="color: #007700">= </span><span style="color: #0000BB">current</span><span style="color: #007700">(</span><span style="color: #0000BB">$transport</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">; </span><span style="color: #FF8000">// $mode = 'foot';<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$mode </span><span style="color: #007700">= </span><span style="color: #0000BB">next</span><span style="color: #007700">(</span><span style="color: #0000BB">$transport</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;    </span><span style="color: #FF8000">// $mode = 'bike';<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$mode </span><span style="color: #007700">= </span><span style="color: #0000BB">current</span><span style="color: #007700">(</span><span style="color: #0000BB">$transport</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">; </span><span style="color: #FF8000">// $mode = 'bike';<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$mode </span><span style="color: #007700">= </span><span style="color: #0000BB">prev</span><span style="color: #007700">(</span><span style="color: #0000BB">$transport</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;    </span><span style="color: #FF8000">// $mode = 'foot';<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$mode </span><span style="color: #007700">= </span><span style="color: #0000BB">end</span><span style="color: #007700">(</span><span style="color: #0000BB">$transport</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;     </span><span style="color: #FF8000">// $mode = 'plane';<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$mode </span><span style="color: #007700">= </span><span style="color: #0000BB">current</span><span style="color: #007700">(</span><span style="color: #0000BB">$transport</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">; </span><span style="color: #FF8000">// $mode = 'plane';<br /><br /></span><span style="color: #0000BB">$arr </span><span style="color: #007700">= array();<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">current</span><span style="color: #007700">(</span><span style="color: #0000BB">$arr</span><span style="color: #007700">)); </span><span style="color: #FF8000">// bool(false)<br /><br /></span><span style="color: #0000BB">$arr </span><span style="color: #007700">= array(array());<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">current</span><span style="color: #007700">(</span><span style="color: #0000BB">$arr</span><span style="color: #007700">)); </span><span style="color: #FF8000">// array(0) { }<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>

 <div class="refsect1 notes" id="refsect1-function.current-notes">
  <h3 class="title">Notas</h3>
  <blockquote class="note"><p><strong class="note">Nota</strong>: 
   <span class="simpara">
    No es posible distinguir el final de un array o el resultado
    de la llamada <span class="function"><strong>current()</strong></span> sobre un array vacío,
    a partir del elemento <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
    Para recorrer correctamente un array que
    puede contener el elemento <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>, ver la estructura de control <a href="control-structures.foreach.php" class="link"><code class="literal">foreach</code></a>.
   </span>
   <span class="simpara">
    Para seguir utilizando <span class="function"><strong>current()</strong></span> y verificar
    correctamente si el valor es realmente un elemento del array,
    la <span class="function"><a href="function.key.php" class="function">key()</a></span> del elemento <span class="function"><strong>current()</strong></span>
    debería compararse estrictamente diferente del elemento <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>.
   </span>
  </p></blockquote>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.current-seealso">
  <h3 class="title">Ver también</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.end.php" class="function" rel="rdfs-seeAlso">end()</a> - Posiciona el puntero del array al final del array</span></li>
    <li><span class="function"><a href="function.key.php" class="function" rel="rdfs-seeAlso">key()</a> - Devuelve una clave de un array asociativo</span></li>
    <li><span class="function"><a href="function.each.php" class="function" rel="rdfs-seeAlso">each()</a> - Devuelve cada par clave/valor de un array</span></li>
    <li><span class="function"><a href="function.prev.php" class="function" rel="rdfs-seeAlso">prev()</a> - Retrocede el puntero actual del array</span></li>
    <li><span class="function"><a href="function.reset.php" class="function" rel="rdfs-seeAlso">reset()</a> - Reinicia el puntero interno del array al principio</span></li>
    <li><span class="function"><a href="function.next.php" class="function" rel="rdfs-seeAlso">next()</a> - Avance el puntero interno de un array</span></li>
    <li><a href="control-structures.foreach.php" class="link"><code class="literal">foreach</code></a></li>
   </ul>
  </p>
 </div>

</div><?php manual_footer($setup); ?>