1
0
mirror of https://github.com/php/doc-ja.git synced 2026-03-25 07:32:13 +01:00
Files
archived-doc-ja/reference/array/functions/array-chunk.xml
TAKAGI Masahiro cdfe3e4bbb sync with en.
git-svn-id: https://svn.php.net/repository/phpdoc/ja/trunk@222583 c90b9560-bf6c-de11-be94-00142212c4b1
2006-10-31 13:44:12 +00:00

110 lines
2.7 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 1.6 $ -->
<!-- EN-Revision: 1.11 Maintainer: hirokawa Status: ready -->
<!-- CREDITS: shimooka -->
<refentry id="function.array-chunk">
<refnamediv>
<refname>array_chunk</refname>
<refpurpose>配列を分割する</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>array</type><methodname>array_chunk</methodname>
<methodparam><type>array</type><parameter>input</parameter></methodparam>
<methodparam><type>int</type><parameter>size</parameter></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>preserve_keys</parameter></methodparam>
</methodsynopsis>
<para>
<function>array_chunk</function> は、各配列が
<parameter>size</parameter> 個の値を有するように配列を複数の配列に分割します。
最後の配列には指定した数よりも少ない個数の値が含まれる可能性があります。
ゼロから始まる添字を有する多次元配列のメンバーとしてこれらの配列を取得します。
</para>
<para>
オプションの引数 <parameter>preserve_keys</parameter>&true;
を設定することにより、配列inputから取得した元のキーを維持させることが可能です。
&false; を指定した場合、返される各配列ではゼロから始まる新しい添字が使用されます。
デフォルトは &false; です。
</para>
<example>
<title><function>array_chunk</function> の例</title>
<programlisting role="php">
<![CDATA[
<?php
$input_array = array('a', 'b', 'c', 'd', 'e');
print_r(array_chunk($input_array, 2));
print_r(array_chunk($input_array, 2, true));
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Array
(
[0] => Array
(
[0] => a
[1] => b
)
[1] => Array
(
[0] => c
[1] => d
)
[2] => Array
(
[0] => e
)
)
Array
(
[0] => Array
(
[0] => a
[1] => b
)
[1] => Array
(
[2] => c
[3] => d
)
[2] => Array
(
[4] => e
)
)
]]>
</screen>
</example>
</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
-->