1
0
mirror of https://github.com/php/doc-zh.git synced 2026-03-25 23:52:17 +01:00
Files
archived-doc-zh/reference/array/functions/current.xml
Dai Jie 264ee58391 Sync array functions .
git-svn-id: https://svn.php.net/repository/phpdoc/zh/trunk@327980 c90b9560-bf6c-de11-be94-00142212c4b1
2012-10-10 12:54:58 +00:00

118 lines
3.3 KiB
XML
Executable File

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- $Author$ -->
<!-- EN-Revision: 89a73e348c5d4bdd0300996566c672035745e2b0 Maintainer: dallas Status: ready -->
<refentry xml:id="function.current" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>current</refname>
<refpurpose>返回数组中的当前单元</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>mixed</type><methodname>current</methodname>
<methodparam><type>array</type><parameter role="reference">array</parameter></methodparam>
</methodsynopsis>
<para>
每个数组中都有一个内部的指针指向它“当前的”单元,初始指向插入到数组中的第一个单元。
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>array</parameter></term>
<listitem>
<para>
这个数组。
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<function>current</function> 函数返回当前被内部指针指向的数组单元的值,并不移动指针。如果内部指针指向超出了单元列表的末端,<function>current</function>
返回 &false;
</para>
&return.falseproblem;
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>使用 <function>current</function> 系列函数的例子</title>
<programlisting role="php">
<![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';
$arr = array();
var_dump(current($arr)); // bool(false)
$arr = array(array());
var_dump(current($arr)); // array(0) { }
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<note>
<simpara>
如果数组包含 <type>boolean</type> &false; 的单元则本函数在碰到这个单元时也返回
&false;,使得不可能判断是否到了此数组列表的末端。
要正确遍历可能含有空单元的数组,用 <function>each</function> 函数。
</simpara>
</note>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<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>
</para>
</refsect1>
</refentry>
<!-- 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
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
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
-->