|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2011-05-19 05:27 UTC] phrisyen at yahoo dot com
 Description:
------------
This is a request for adding another flag (FILTER_FLAG_ALLOW_ARRAY) to filter extension to allow both arrays and scalars for input, while retaining their type (as opposed to FILTER_FORCE_ARRAY, which can accept scalars, but will return an array).
So if input is array, return an array, and if scalar, return scalar.
It seems pretty basic.
Test script:
---------------
$test = filter_input(INPUT_GET, "a", FILTER_VALIDATE_INT, FILTER_FLAG_ALLOW_ARRAY);
var_dump($test);
Expected result:
----------------
test.php?a=1
int(1)
test.php?a[]=1&a[]=2
array (2) { [0] => int(1), [1] => int(2) }
Actual result:
--------------
FILTER_FLAG_ALLOW_ARRAY not implemented ;)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 17:00:02 2025 UTC | 
I can't filter an array value (comming from a set of checkboxes) with input_filter. Reproduction: var_dump($_POST['options'], filter_input(INPUT_POST, 'options')); Result: array(2) { [1]=> string(5) "first" [2]=> string(6) "second" } bool(false)