1
0
mirror of https://github.com/php/doc-zh.git synced 2026-03-24 15:12:20 +01:00
Files
archived-doc-zh/reference/array/functions/array-slice.xml
Dallas Wang 877f5fa4fc Translation completed.
git-svn-id: https://svn.php.net/repository/phpdoc/zh/trunk@95317 c90b9560-bf6c-de11-be94-00142212c4b1
2002-09-09 21:00:24 +00:00

79 lines
2.6 KiB
XML
Executable File

<?xml version="1.0" encoding="gb2312"?>
<!-- $Revision: 1.1 $ -->
<!-- $Author: dallas $ -->
<!-- EN-Revision: 1.4 Maintainer: dallas Status: ready -->
<refentry id="function.array-slice">
<refnamediv>
<refname>array_slice</refname>
<refpurpose>从数组中取出一段</refpurpose>
</refnamediv>
<refsect1>
<title>说明</title>
<methodsynopsis>
<type>array</type><methodname>array_slice</methodname>
<methodparam><type>array</type><parameter>array</parameter></methodparam>
<methodparam><type>int</type><parameter>offset</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>
length
</parameter></methodparam>
</methodsynopsis>
<para>
<function>array_slice</function> 返回根据 <parameter>offset</parameter>
<parameter>length</parameter> 参数所指定的 <parameter>array</parameter>
数组中的一段序列。
</para>
<para>
如果 <parameter>offset</parameter> 为正,则序列将从 <parameter>array</parameter>
中的此偏移量开始。如果 <parameter>offset</parameter> 为负,则序列将从
<parameter>array</parameter> 中距离末端这么远的地方开始。
</para>
<para>
如果给出了 <parameter>length</parameter> 并且为正,则序列中将具有这么多的单元。如果给出了
<parameter>length</parameter> 并且为负,则序列将终止在距离数组末端这么远的地方。如果省略,则序列将从
<parameter>offset</parameter> 开始一直到 <parameter>array</parameter> 的末端。
</para>
<para>
注意 <function>array_slice</function> 将忽略键名,并且是根据单元在数组中的实际位置来计算偏移量和长度的。
</para>
<para>
<example>
<title><function>array_slice</function> 例子</title>
<programlisting role="php">
<![CDATA[
$input = array ("a", "b", "c", "d", "e");
$output = array_slice ($input, 2); // returns "c", "d", and "e"
$output = array_slice ($input, 2, -1); // returns "c", "d"
$output = array_slice ($input, -2, 1); // returns "d"
$output = array_slice ($input, 0, 3); // returns "a", "b", and "c"
]]>
</programlisting>
</example>
</para>
<para>
参见 <function>array_splice</function>
</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:"../../../../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
-->