mirror of
https://github.com/php/doc-ru.git
synced 2026-03-24 15:52:13 +01:00
195 lines
6.1 KiB
XML
195 lines
6.1 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
||
<!-- EN-Revision: c142be811735a5542c8a2e4c4ed2f81e8cc3acc6 Maintainer: tmn Status: ready -->
|
||
<!-- Reviewed: no -->
|
||
<refentry xml:id="recursiveiteratoriterator.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||
<refnamediv>
|
||
<refname>RecursiveIteratorIterator::__construct</refname>
|
||
<refpurpose>Конструктор класса RecursiveIteratorIterator</refpurpose>
|
||
</refnamediv>
|
||
|
||
<refsect1 role="description">
|
||
&reftitle.description;
|
||
<constructorsynopsis role="RecursiveIteratorIterator">
|
||
<modifier>public</modifier> <methodname>RecursiveIteratorIterator::__construct</methodname>
|
||
<methodparam><type>Traversable</type><parameter>iterator</parameter></methodparam>
|
||
<methodparam choice="opt"><type>int</type><parameter>mode</parameter><initializer><constant>RecursiveIteratorIterator::LEAVES_ONLY</constant></initializer></methodparam>
|
||
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>0</initializer></methodparam>
|
||
</constructorsynopsis>
|
||
<para>
|
||
Создаёт новый объект класса <classname>RecursiveIteratorIterator</classname>
|
||
на основе объекта <classname>RecursiveIterator</classname>.
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="parameters">
|
||
&reftitle.parameters;
|
||
<para>
|
||
<variablelist>
|
||
<varlistentry>
|
||
<term><parameter>iterator</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
Объект-итератор, на основе которого требуется построить данный экземпляр.
|
||
Это может быть объект класса <classname>RecursiveIterator</classname>
|
||
или класса <classname>IteratorAggregate</classname>.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
<varlistentry>
|
||
<term><parameter>mode</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
Необязательный параметр. Задание режима работы конструктора. Возможные
|
||
значения:
|
||
<simplelist>
|
||
<member>
|
||
<constant>RecursiveIteratorIterator::LEAVES_ONLY</constant>
|
||
- По умолчанию. Итерация будет осуществляться только по листам дерева
|
||
элементов.
|
||
</member>
|
||
<member>
|
||
<constant>RecursiveIteratorIterator::SELF_FIRST</constant>
|
||
- Итерация будет осуществляться по всему дереву элементов, причём
|
||
первыми будут идти родительские элементы.
|
||
</member>
|
||
<member>
|
||
<constant>RecursiveIteratorIterator::CHILD_FIRST</constant>
|
||
- Итерация будет осуществляться по всему дереву элементов, причём
|
||
первыми будут идти дочерние элементы.
|
||
</member>
|
||
</simplelist>
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
<varlistentry>
|
||
<term><parameter>flags</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
Необязательный настроечный флаг. Возможное значение
|
||
<constant>RecursiveIteratorIterator::CATCH_GET_CHILD</constant> даёт
|
||
предписание объекту не принимать во внимание исключения, которые
|
||
вызывает метод
|
||
<methodname>RecursiveIteratorIterator::getChildren</methodname>.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
</variablelist>
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="examples"><!-- {{{ -->
|
||
&reftitle.examples;
|
||
<para>
|
||
<example xml:id="recursiveiteratoriterator.example.basic"><!-- {{{ -->
|
||
<title>Итерация по дереву элементов с помощью RecursiveIteratorIterator</title>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?php
|
||
$array = array(
|
||
array(
|
||
array(
|
||
array(
|
||
'leaf-0-0-0-0',
|
||
'leaf-0-0-0-1'
|
||
),
|
||
'leaf-0-0-0'
|
||
),
|
||
array(
|
||
array(
|
||
'leaf-0-1-0-0',
|
||
'leaf-0-1-0-1'
|
||
),
|
||
'leaf-0-1-0'
|
||
),
|
||
'leaf-0-0'
|
||
)
|
||
);
|
||
|
||
$iterator = new RecursiveIteratorIterator(
|
||
new RecursiveArrayIterator($array),
|
||
$mode
|
||
);
|
||
foreach ($iterator as $key => $leaf) {
|
||
echo "$key => $leaf", PHP_EOL;
|
||
}
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
<para xml:id="recursiveiteratoriterator.examples.basic.leaves-only">
|
||
Вывод примера в режиме <literal>$mode = RecursiveIteratorIterator::LEAVES_ONLY</literal>
|
||
</para>
|
||
<screen>
|
||
<![CDATA[
|
||
0 => leaf-0-0-0-0
|
||
1 => leaf-0-0-0-1
|
||
0 => leaf-0-0-0
|
||
0 => leaf-0-1-0-0
|
||
1 => leaf-0-1-0-1
|
||
0 => leaf-0-1-0
|
||
0 => leaf-0-0
|
||
]]>
|
||
</screen>
|
||
<para xml:id="recursiveiteratoriterator.examples.basic.self-first">
|
||
Вывод примера в режиме <literal>$mode = RecursiveIteratorIterator::SELF_FIRST</literal>
|
||
</para>
|
||
<screen>
|
||
<![CDATA[
|
||
0 => Array
|
||
0 => Array
|
||
0 => Array
|
||
0 => leaf-0-0-0-0
|
||
1 => leaf-0-0-0-1
|
||
1 => leaf-0-0-0
|
||
1 => Array
|
||
0 => Array
|
||
0 => leaf-0-1-0-0
|
||
1 => leaf-0-1-0-1
|
||
1 => leaf-0-1-0
|
||
2 => leaf-0-0
|
||
]]>
|
||
</screen>
|
||
<para xml:id="recursiveiteratoriterator.examples.basic.child-first">
|
||
Вывод примера в режиме <literal>$mode = RecursiveIteratorIterator::CHILD_FIRST</literal>
|
||
</para>
|
||
<screen>
|
||
<![CDATA[
|
||
0 => leaf-0-0-0-0
|
||
1 => leaf-0-0-0-1
|
||
0 => Array
|
||
1 => leaf-0-0-0
|
||
0 => Array
|
||
0 => leaf-0-1-0-0
|
||
1 => leaf-0-1-0-1
|
||
0 => Array
|
||
1 => leaf-0-1-0
|
||
1 => Array
|
||
2 => leaf-0-0
|
||
0 => Array
|
||
]]>
|
||
</screen>
|
||
</example><!-- }}} -->
|
||
</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
|
||
-->
|