ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[TOC] ## 概述 filter_var_array 与 filter_input_array 用法类似 ## 实例 ### 基础实例 ``` $data = [ 'product_id' => 'libgd<script>', 'component' => '10', 'versions' => '2.0.33', 'testscalar' => ['2', '23', '10', '12'], 'testarray' => '2', ]; $args = [ 'product_id' => FILTER_SANITIZE_ENCODED, 'component' => ['filter' => FILTER_VALIDATE_INT, 'flags' => FILTER_FORCE_ARRAY, 'options' => ['min_range' => 1, 'max_range' => 10] ], 'versions' => FILTER_SANITIZE_ENCODED, 'doesnotexist' => FILTER_VALIDATE_INT, 'testscalar' => [ 'filter' => FILTER_VALIDATE_INT, 'flags' => FILTER_REQUIRE_SCALAR, ], 'testarray' => [ 'filter' => FILTER_VALIDATE_INT, 'flags' => FILTER_FORCE_ARRAY, ] ]; $myinputs = filter_var_array($data, $args); print_r($myinputs); ```