mirror of
https://github.com/php/doc-ja.git
synced 2026-03-25 07:32:13 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/ja/trunk@222583 c90b9560-bf6c-de11-be94-00142212c4b1
104 lines
3.2 KiB
XML
104 lines
3.2 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision: 1.8 $ -->
|
|
<!-- EN-Revision: 1.13 Maintainer: hirokawa 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>
|
|
<methodparam choice="opt"><type>bool</type><parameter>preserve_keys</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>array_slice</function>は、<parameter>array</parameter>
|
|
から引数 <parameter>offset</parameter> および
|
|
<parameter>length</parameter> で指定された連続する要素を返します。
|
|
</para>
|
|
<para>
|
|
<parameter>offset</parameter> が負の値ではない場合、要素位置の計算は、
|
|
配列 <parameter>array</parameter> の offset から始められます。
|
|
<parameter>offset</parameter> が負の場合、要素位置の計算は
|
|
<parameter>array</parameter> の最後から行われます。
|
|
</para>
|
|
<para>
|
|
<parameter>length</parameter>が指定され、正の場合、
|
|
連続する複数の要素が返されます。<parameter>length</parameter>
|
|
が指定され、負の場合、配列の末尾から連続する複数の要素が返されます。
|
|
省略された場合、<parameter>offset</parameter>
|
|
から配列の最後までの全ての要素が返されます。
|
|
</para>
|
|
<para>
|
|
<function>array_slice</function> はデフォルトで配列の数値キーを
|
|
リセットすることに注意してください。PHP 5.0.2 からは、
|
|
<parameter>preserve_keys</parameter> を &true;
|
|
にする事でこの動作を変更することができます。
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title><function>array_slice</function> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$input = array("a", "b", "c", "d", "e");
|
|
|
|
$output = array_slice($input, 2); // "c", "d", "e" を返す
|
|
$output = array_slice($input, -2, 1); // "d" を返す
|
|
$output = array_slice($input, 0, 3); // "a", "b", "c" を返す
|
|
|
|
// 配列キーの違いに注意
|
|
print_r(array_slice($input, 2, -1));
|
|
print_r(array_slice($input, 2, -1, true));
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[0] => c
|
|
[1] => d
|
|
)
|
|
Array
|
|
(
|
|
[2] => c
|
|
[3] => d
|
|
)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<function>array_splice</function> および
|
|
<function>unset</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
|
|
-->
|