<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.filter.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.filter-var-array.php',
    1 => 'filter_var_array',
    2 => 'Gets multiple variables and optionally filters them',
  ),
  'up' => 
  array (
    0 => 'ref.filter.php',
    1 => 'Функції Filter',
  ),
  'prev' => 
  array (
    0 => 'function.filter-var.php',
    1 => 'filter_var',
  ),
  'next' => 
  array (
    0 => 'book.funchand.php',
    1 => 'Обробка функцій',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/filter/functions/filter-var-array.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.filter-var-array" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">filter_var_array</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.2.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">filter_var_array</span> &mdash; <span class="dc-title">Gets multiple variables and optionally filters them</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.filter-var-array-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>filter_var_array</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$array</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.integer.php" class="type int">int</a></span></span> <code class="parameter">$options</code><span class="initializer"> = <strong><code><a href="filter.constants.php#constant.filter-default">FILTER_DEFAULT</a></code></strong></span></span>, <span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$add_empty</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span>|<span class="type"><a href="language.types.null.php" class="type null">null</a></span></span></div>

  <p class="simpara">
   Filter an associative <span class="type"><a href="language.types.array.php" class="type array">array</a></span> of values using
   <strong><code><a href="filter.constants.php#constant.filter-validate-bool">FILTER_VALIDATE_<span class="replaceable">*</span></a></code></strong>
   validation filters,
   <strong><code><a href="filter.constants.php#constant.filter-sanitize-string">FILTER_SANITIZE_<span class="replaceable">*</span></a></code></strong>
   sanitization filters, or custom filters.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.filter-var-array-parameters">
  <h3 class="title">Параметри</h3>
  <dl>
   
    <dt><code class="parameter">array</code></dt>
    <dd>
     <span class="simpara">
      An associative <span class="type"><a href="language.types.array.php" class="type array">array</a></span> containing the data to filter.
     </span>
    </dd>
   
   
    <dt><code class="parameter">options</code></dt>
    <dd>
     <span class="simpara">
      Either an associative <span class="type"><a href="language.types.array.php" class="type array">array</a></span> of options,
      or the filter to apply to each entry,
      which can either be a validation filter by using one of the
      <strong><code><a href="filter.constants.php#constant.filter-validate-bool">FILTER_VALIDATE_<span class="replaceable">*</span></a></code></strong>
      constants, or a sanitization filter by using one of the
      <strong><code><a href="filter.constants.php#constant.filter-sanitize-string">FILTER_SANITIZE_<span class="replaceable">*</span></a></code></strong>
      constants.
     </span>
     <span class="simpara">
      The option array is an associative array where the key corresponds
      to a key in the data <code class="parameter">array</code> and the associated
      value is either the filter to apply to this entry,
      or an associative array describing how and which filter should be
      applied to this entry.
     </span>
     <span class="simpara">
      The associative array describing how a filter should be applied
      must contain the <code class="literal">&#039;filter&#039;</code> key whose associated
      value is the filter to apply, which can be one of the
      <strong><code><a href="filter.constants.php#constant.filter-validate-bool">FILTER_VALIDATE_<span class="replaceable">*</span></a></code></strong>,
      <strong><code><a href="filter.constants.php#constant.filter-sanitize-string">FILTER_SANITIZE_<span class="replaceable">*</span></a></code></strong>,
      <strong><code><a href="filter.constants.php#constant.filter-unsafe-raw">FILTER_UNSAFE_RAW</a></code></strong>, or
      <strong><code><a href="filter.constants.php#constant.filter-callback">FILTER_CALLBACK</a></code></strong> constants.
      It can optionally contain the <code class="literal">&#039;flags&#039;</code> key
      which specifies and flags that apply to the filter,
      and the <code class="literal">&#039;options&#039;</code> key which specifies any options
      that apply to the filter.
     </span>
    </dd>
   
   
    <dt><code class="parameter">add_empty</code></dt>
    <dd>
     <p class="para">
      Add missing keys as <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> to the return value.
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.filter-var-array-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   An array containing the values of the requested variables on success, or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> 
   on failure. An array value will be <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> if the filter fails, or <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> if 
   the variable is not set.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.filter-var-array-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 A <span class="function"><strong>filter_var_array()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$data </span><span style="color: #007700">= [<br />    </span><span style="color: #DD0000">'product_id' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'libgd&lt;script&gt;'</span><span style="color: #007700">,<br />    </span><span style="color: #DD0000">'component'  </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'10'</span><span style="color: #007700">,<br />    </span><span style="color: #DD0000">'versions'   </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'2.0.33'</span><span style="color: #007700">,<br />    </span><span style="color: #DD0000">'testscalar' </span><span style="color: #007700">=&gt; [</span><span style="color: #DD0000">'2'</span><span style="color: #007700">, </span><span style="color: #DD0000">'23'</span><span style="color: #007700">, </span><span style="color: #DD0000">'10'</span><span style="color: #007700">, </span><span style="color: #DD0000">'12'</span><span style="color: #007700">],<br />    </span><span style="color: #DD0000">'testarray'  </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'2'</span><span style="color: #007700">,<br />];<br /><br /></span><span style="color: #0000BB">$filters </span><span style="color: #007700">= [<br />    </span><span style="color: #DD0000">'product_id'   </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">FILTER_SANITIZE_ENCODED</span><span style="color: #007700">,<br />    </span><span style="color: #DD0000">'component'    </span><span style="color: #007700">=&gt; [<br />        </span><span style="color: #DD0000">'filter'   </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">FILTER_VALIDATE_INT</span><span style="color: #007700">,<br />        </span><span style="color: #DD0000">'flags'    </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">FILTER_FORCE_ARRAY</span><span style="color: #007700">,<br />        </span><span style="color: #DD0000">'options'  </span><span style="color: #007700">=&gt; [<br />            </span><span style="color: #DD0000">'min_range' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">1</span><span style="color: #007700">,<br />            </span><span style="color: #DD0000">'max_range' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">10</span><span style="color: #007700">,<br />        ],<br />    ],<br />    </span><span style="color: #DD0000">'versions'     </span><span style="color: #007700">=&gt; [<br />        </span><span style="color: #DD0000">'filter' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">FILTER_SANITIZE_ENCODED<br />    </span><span style="color: #007700">],<br />    </span><span style="color: #DD0000">'testscalar'   </span><span style="color: #007700">=&gt; [<br />        </span><span style="color: #DD0000">'filter' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">FILTER_VALIDATE_INT</span><span style="color: #007700">,<br />        </span><span style="color: #DD0000">'flags'  </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">FILTER_REQUIRE_SCALAR</span><span style="color: #007700">,<br />    ],<br />    </span><span style="color: #DD0000">'testarray'    </span><span style="color: #007700">=&gt; [<br />        </span><span style="color: #DD0000">'filter' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">FILTER_VALIDATE_INT</span><span style="color: #007700">,<br />        </span><span style="color: #DD0000">'flags'  </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">FILTER_FORCE_ARRAY</span><span style="color: #007700">,<br />    ],<br />    </span><span style="color: #DD0000">'doesnotexist' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">FILTER_VALIDATE_INT</span><span style="color: #007700">,<br />];<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">filter_var_array</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">, </span><span style="color: #0000BB">$filters</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Поданий вище приклад
виведе:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">array(6) {
  [&quot;product_id&quot;]=&gt;
  string(17) &quot;libgd%3Cscript%3E&quot;
  [&quot;component&quot;]=&gt;
  array(1) {
    [0]=&gt;
    int(10)
  }
  [&quot;versions&quot;]=&gt;
  string(6) &quot;2.0.33&quot;
  [&quot;testscalar&quot;]=&gt;
  bool(false)
  [&quot;testarray&quot;]=&gt;
  array(1) {
    [0]=&gt;
    int(2)
  }
  [&quot;doesnotexist&quot;]=&gt;
  NULL
}</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.filter-var-array-seealso">
  <h3 class="title">Прогляньте також</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.filter-input-array.php" class="function" rel="rdfs-seeAlso">filter_input_array()</a> - Gets external variables and optionally filters them</span></li>
   <li><span class="function"><a href="function.filter-var.php" class="function" rel="rdfs-seeAlso">filter_var()</a> - Filters a variable with a specified filter</span></li>
   <li><span class="function"><a href="function.filter-input.php" class="function" rel="rdfs-seeAlso">filter_input()</a> - Gets a specific external variable by name and optionally filters it</span></li>
   <li>
    Validation filters
    <strong><code><a href="filter.constants.php#constant.filter-validate-bool">FILTER_VALIDATE_<span class="replaceable">*</span></a></code></strong>
   </li>
   <li>
    Sanitization filters
    <strong><code><a href="filter.constants.php#constant.filter-sanitize-string">FILTER_SANITIZE_<span class="replaceable">*</span></a></code></strong>
   </li>
  </ul>
 </div>


</div><?php manual_footer($setup); ?>