mirror of
https://github.com/php/doc-ja.git
synced 2026-03-24 15:12:22 +01:00
161 lines
4.4 KiB
XML
Executable File
161 lines
4.4 KiB
XML
Executable File
<?xml version='1.0' encoding='utf-8'?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: cec5275f23d2db648df30a5702b378044431be97 Maintainer: takagi Status: ready -->
|
|
<!-- Credits: mumumu -->
|
|
<refentry xml:id="function.array-walk-recursive" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>array_walk_recursive</refname>
|
|
<refpurpose>配列の全ての要素に、ユーザー関数を再帰的に適用する</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>true</type><methodname>array_walk_recursive</methodname>
|
|
<methodparam><type class="union"><type>array</type><type>object</type></type><parameter role="reference">array</parameter></methodparam>
|
|
<methodparam><type>callable</type><parameter>callback</parameter></methodparam>
|
|
<methodparam choice="opt"><type>mixed</type><parameter>arg</parameter><initializer>&null;</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<parameter>array</parameter> 配列の各要素にユーザー定義関数
|
|
<parameter>callback</parameter>を適用します。
|
|
この関数は配列の要素内を再帰的にたどっていきます。
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>array</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
入力の配列。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>callback</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
通常、
|
|
<parameter>callback</parameter> は引数を二つとります。
|
|
<parameter>array</parameter> パラメータの値が最初の引数、
|
|
キー/添字は二番目の引数となります。
|
|
</para>
|
|
<note>
|
|
<para>
|
|
<parameter>callback</parameter> により配列の値そのものを変更する必要がある場合、
|
|
<parameter>callback</parameter> の最初の引数は
|
|
<link linkend="language.references">リファレンス</link>
|
|
として渡す必要があります。この場合、配列の要素に加えた変更は、
|
|
配列自体に対して行われます。
|
|
</para>
|
|
</note>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>arg</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
オプションの <parameter>arg</parameter> パラメータが指定された場合、
|
|
コールバック関数 <parameter>callback</parameter> への三番目の引数として渡されます。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&return.true.always;
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
&return.type.true;
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>array_walk_recursive</function> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$sweet = array('a' => 'apple', 'b' => 'banana');
|
|
$fruits = array('sweet' => $sweet, 'sour' => 'lemon');
|
|
|
|
function test_print($item, $key)
|
|
{
|
|
echo "$key holds $item\n";
|
|
}
|
|
|
|
array_walk_recursive($fruits, 'test_print');
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen role="php">
|
|
<![CDATA[
|
|
a holds apple
|
|
b holds banana
|
|
sour holds lemon
|
|
]]>
|
|
</screen>
|
|
<para>
|
|
キー '<literal>sweet</literal>' が表示されないことにお気づきでしょう。<type>array</type>
|
|
を要素として持つキーは関数に渡されません。
|
|
</para>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>array_walk</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
|
|
-->
|