<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/spl.iterators.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'class.recursivecallbackfilteriterator.php',
    1 => 'RecursiveCallbackFilterIterator',
    2 => 'The RecursiveCallbackFilterIterator class',
  ),
  'up' => 
  array (
    0 => 'spl.iterators.php',
    1 => 'Iterators',
  ),
  'prev' => 
  array (
    0 => 'recursivecachingiterator.haschildren.php',
    1 => 'RecursiveCachingIterator::hasChildren',
  ),
  'next' => 
  array (
    0 => 'recursivecallbackfilteriterator.construct.php',
    1 => 'RecursiveCallbackFilterIterator::__construct',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/spl/recursivecallbackfilteriterator.xml',
  ),
  'history' => 
  array (
  ),
  'extra_header_links' => 
  array (
    'rel' => 'alternate',
    'href' => '/manual/en/feeds/class.recursivecallbackfilteriterator.atom',
    'type' => 'application/atom+xml',
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="class.recursivecallbackfilteriterator" class="reference">

 <h1 class="title">The RecursiveCallbackFilterIterator class</h1>
 

 <div class="partintro"><p class="verinfo">(PHP 5 &gt;= 5.4.0, PHP 7, PHP 8)</p>


  <div class="section" id="recursivecallbackfilteriterator.intro">
   <h2 class="title">Вступ</h2>
   <p class="para">

   </p>
  </div>


  <div class="section" id="recursivecallbackfilteriterator.synopsis">
   <h2 class="title">Короткий огляд класу</h2>


   <div class="classsynopsis"><div class="classsynopsisinfo">
    
     <span class="modifier">class</span> <strong class="classname"><strong class="classname">RecursiveCallbackFilterIterator</strong></strong>
    

    
     <span class="modifier">extends</span>
      <a href="class.callbackfilteriterator.php" class="classname">CallbackFilterIterator</a>
    

    
     <span class="modifier">implements</span>
      <a href="class.recursiveiterator.php" class="interfacename">RecursiveIterator</a> {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Методи */</div>
    <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="recursivecallbackfilteriterator.construct.php" class="methodname">__construct</a></span>(<span class="methodparam"><span class="type"><a href="class.recursiveiterator.php" class="type RecursiveIterator">RecursiveIterator</a></span> <code class="parameter">$iterator</code></span>, <span class="methodparam"><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>)</div>

    <div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="recursivecallbackfilteriterator.getchildren.php" class="methodname">getChildren</a></span>(): <span class="type"><a href="class.recursivecallbackfilteriterator.php" class="type RecursiveCallbackFilterIterator">RecursiveCallbackFilterIterator</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="recursivecallbackfilteriterator.haschildren.php" class="methodname">hasChildren</a></span>(): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Успадковані методи */</div>
    <div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="callbackfilteriterator.accept.php" class="methodname">CallbackFilterIterator::accept</a></span>(): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

    <div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="filteriterator.accept.php" class="methodname">FilterIterator::accept</a></span>(): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="filteriterator.current.php" class="methodname">FilterIterator::current</a></span>(): <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="filteriterator.key.php" class="methodname">FilterIterator::key</a></span>(): <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="filteriterator.next.php" class="methodname">FilterIterator::next</a></span>(): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="filteriterator.rewind.php" class="methodname">FilterIterator::rewind</a></span>(): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="filteriterator.valid.php" class="methodname">FilterIterator::valid</a></span>(): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

    <div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="iteratoriterator.current.php" class="methodname">IteratorIterator::current</a></span>(): <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="iteratoriterator.getinneriterator.php" class="methodname">IteratorIterator::getInnerIterator</a></span>(): <span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="class.iterator.php" class="type Iterator">Iterator</a></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="iteratoriterator.key.php" class="methodname">IteratorIterator::key</a></span>(): <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="iteratoriterator.next.php" class="methodname">IteratorIterator::next</a></span>(): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="iteratoriterator.rewind.php" class="methodname">IteratorIterator::rewind</a></span>(): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="iteratoriterator.valid.php" class="methodname">IteratorIterator::valid</a></span>(): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

   }</div>


  </div>

  
  <div class="section" id="recursivecallbackfilteriterator.examples">
   <h2 class="title">Приклади</h2>
   <p class="para">
    The callback should accept up to three arguments:
    the current item, the current key and the iterator, respectively.
   </p>
   <div class="example" id="recursivecallbackfilteriterator.examples.args">
    <p><strong>Приклад #1 Available callback arguments</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">/**<br /> * Callback for RecursiveCallbackFilterIterator<br /> *<br /> * @param $current   Current item's value<br /> * @param $key       Current item's key<br /> * @param $iterator  Iterator being filtered<br /> * @return boolean   TRUE to accept the current item, FALSE otherwise<br /> */<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">my_callback</span><span style="color: #007700">(</span><span style="color: #0000BB">$current</span><span style="color: #007700">, </span><span style="color: #0000BB">$key</span><span style="color: #007700">, </span><span style="color: #0000BB">$iterator</span><span style="color: #007700">) {<br />    </span><span style="color: #FF8000">// Your filtering code here<br /></span><span style="color: #007700">}<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
   <p class="para">
    Filtering a recursive iterator generally involves two conditions.
    The first is that, to allow recursion, the callback function should return <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>
    if the current iterator item has children.
    The second is the normal filter condition, such as a file size or extension 
    check as in the example below.
   </p>
   <div class="example" id="recursivecallbackfilteriterator.examples.basic">
    <p><strong>Приклад #2 Recursive callback basic example</strong></p>
<div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$dir </span><span style="color: #007700">= new </span><span style="color: #0000BB">RecursiveDirectoryIterator</span><span style="color: #007700">(</span><span style="color: #0000BB">__DIR__</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Filter large files ( &gt; 100MB)<br /></span><span style="color: #0000BB">$files </span><span style="color: #007700">= new </span><span style="color: #0000BB">RecursiveCallbackFilterIterator</span><span style="color: #007700">(</span><span style="color: #0000BB">$dir</span><span style="color: #007700">, function (</span><span style="color: #0000BB">$current</span><span style="color: #007700">, </span><span style="color: #0000BB">$key</span><span style="color: #007700">, </span><span style="color: #0000BB">$iterator</span><span style="color: #007700">) {<br />    </span><span style="color: #FF8000">// Allow recursion<br />    </span><span style="color: #007700">if (</span><span style="color: #0000BB">$iterator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">hasChildren</span><span style="color: #007700">()) {<br />        return </span><span style="color: #0000BB">TRUE</span><span style="color: #007700">;<br />    }<br />    </span><span style="color: #FF8000">// Check for large file<br />    </span><span style="color: #007700">if (</span><span style="color: #0000BB">$current</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">isFile</span><span style="color: #007700">() &amp;&amp; </span><span style="color: #0000BB">$current</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getSize</span><span style="color: #007700">() &gt; </span><span style="color: #0000BB">104857600</span><span style="color: #007700">) {<br />        return </span><span style="color: #0000BB">TRUE</span><span style="color: #007700">;<br />    }<br />    return </span><span style="color: #0000BB">FALSE</span><span style="color: #007700">;<br />});<br /> <br />foreach (new </span><span style="color: #0000BB">RecursiveIteratorIterator</span><span style="color: #007700">(</span><span style="color: #0000BB">$files</span><span style="color: #007700">) as </span><span style="color: #0000BB">$file</span><span style="color: #007700">) {<br />    echo </span><span style="color: #0000BB">$file</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getPathname</span><span style="color: #007700">() . </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </div>
  

 </div>

 















<h2>Зміст</h2><ul class="chunklist chunklist_reference"><li><a href="recursivecallbackfilteriterator.construct.php">RecursiveCallbackFilterIterator::__construct</a> — Create a RecursiveCallbackFilterIterator from a RecursiveIterator</li><li><a href="recursivecallbackfilteriterator.getchildren.php">RecursiveCallbackFilterIterator::getChildren</a> — Return the inner iterator's children contained in a RecursiveCallbackFilterIterator</li><li><a href="recursivecallbackfilteriterator.haschildren.php">RecursiveCallbackFilterIterator::hasChildren</a> — Check whether the inner iterator's current element has children</li></ul>
</div>
<?php manual_footer($setup); ?>