2010-03-28 22:10:10 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2009-07-11 06:30:45 +00:00
|
|
|
<!-- $Revision$ -->
|
2007-06-20 22:25:43 +00:00
|
|
|
<refentry xml:id="function.current" xmlns="http://docbook.org/ns/docbook">
|
2006-10-31 11:24:02 +00:00
|
|
|
<refnamediv>
|
|
|
|
<refname>current</refname>
|
|
|
|
<refpurpose>Return the current element in an array</refpurpose>
|
|
|
|
</refnamediv>
|
2007-12-30 19:17:05 +00:00
|
|
|
<refsect1 role="description">
|
|
|
|
&reftitle.description;
|
2006-10-31 11:24:02 +00:00
|
|
|
<methodsynopsis>
|
|
|
|
<type>mixed</type><methodname>current</methodname>
|
2011-04-17 09:37:40 +00:00
|
|
|
<methodparam><type>array</type><parameter role="reference">array</parameter></methodparam>
|
2006-10-31 11:24:02 +00:00
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
|
|
|
Every array has an internal pointer to its "current" element,
|
|
|
|
which is initialized to the first element inserted into the
|
|
|
|
array.
|
|
|
|
</para>
|
2007-12-30 19:17:05 +00:00
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
|
|
&reftitle.parameters;
|
|
|
|
<para>
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>array</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
The array.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
|
|
&reftitle.returnvalues;
|
2006-10-31 11:24:02 +00:00
|
|
|
<para>
|
|
|
|
The <function>current</function> function simply returns the
|
|
|
|
value of the array element that's currently being pointed to by the
|
|
|
|
internal pointer. It does not move the pointer in any way. If the
|
2008-01-06 12:30:42 +00:00
|
|
|
internal pointer points beyond the end of the elements list or the array is
|
|
|
|
empty, <function>current</function> returns &false;.
|
2006-10-31 11:24:02 +00:00
|
|
|
</para>
|
|
|
|
&return.falseproblem;
|
2007-12-30 19:17:05 +00:00
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
|
|
&reftitle.examples;
|
2006-10-31 11:24:02 +00:00
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title>Example use of <function>current</function> and friends</title>
|
|
|
|
<programlisting role="php">
|
2003-07-18 08:31:09 +00:00
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
$transport = array('foot', 'bike', 'car', 'plane');
|
|
|
|
$mode = current($transport); // $mode = 'foot';
|
|
|
|
$mode = next($transport); // $mode = 'bike';
|
|
|
|
$mode = current($transport); // $mode = 'bike';
|
|
|
|
$mode = prev($transport); // $mode = 'foot';
|
|
|
|
$mode = end($transport); // $mode = 'plane';
|
|
|
|
$mode = current($transport); // $mode = 'plane';
|
2008-01-06 12:30:42 +00:00
|
|
|
|
|
|
|
$arr = array();
|
|
|
|
var_dump(current($arr)); // bool(false)
|
|
|
|
|
|
|
|
$arr = array(array());
|
|
|
|
var_dump(current($arr)); // array(0) { }
|
2003-07-18 08:31:09 +00:00
|
|
|
?>
|
|
|
|
]]>
|
2006-10-31 11:24:02 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
2007-12-30 19:17:05 +00:00
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
|
|
&reftitle.notes;
|
|
|
|
<note>
|
|
|
|
<simpara>
|
|
|
|
You won't be able to distinguish the end of an array from a
|
|
|
|
<type>boolean</type> &false; element. To properly traverse an array
|
|
|
|
which may contain &false; elements, see the <function>each</function>
|
|
|
|
function.
|
|
|
|
</simpara>
|
|
|
|
</note>
|
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
|
|
&reftitle.seealso;
|
2006-10-31 11:24:02 +00:00
|
|
|
<para>
|
2007-12-30 19:17:05 +00:00
|
|
|
<simplelist>
|
|
|
|
<member><function>end</function></member>
|
|
|
|
<member><function>key</function></member>
|
|
|
|
<member><function>each</function></member>
|
|
|
|
<member><function>prev</function></member>
|
|
|
|
<member><function>reset</function></member>
|
|
|
|
<member><function>next</function></member>
|
|
|
|
</simplelist>
|
2006-10-31 11:24:02 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
2002-04-15 00:12:54 +00:00
|
|
|
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
sgml-parent-document:nil
|
2009-09-25 07:04:39 +00:00
|
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
2002-04-15 00:12:54 +00:00
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
|
|
|
-->
|