php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41110 Filter extension doesn't allow GET/POST array parameters
Submitted: 2007-04-17 02:51 UTC Modified: 2007-04-17 06:44 UTC
From: mauroi at digbang dot com Assigned: pajoye (profile)
Status: Not a bug Package: Filter related
PHP Version: 5.2.1 OS: Linux & Windows
Private report: No CVE-ID: None
 [2007-04-17 02:51 UTC] mauroi at digbang dot com
Description:
------------
I'm trying to use an old way of sending arrays between pages in PHP with the new filter extension. With normal superglobals if you append '[]' after a parameter's name, you get an array with one element for each aparence.

Eg,
http://localhost/foo.php?a[]=1&a[]=2
results in an array with two positions in $_GET['a'].

I'm not being able to emulate this behavior with the filter extension.


Reproduce code:
---------------
<pre>
<?
var_dump($_GET['a']);
var_dump(filter_input(INPUT_GET, 'a', FILTER_DEFAULT))
?>
</pre>

Expected result:
----------------
array(2) {
  [0]=>
  string(1) "1"
  [1]=>
  string(1) "2"
}
array(2) {
  [0]=>
  string(1) "1"
  [1]=>
  string(1) "2"
}

Actual result:
--------------
array(2) {
  [0]=>
  string(1) "1"
  [1]=>
  string(1) "2"
}
bool(false)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-17 06:44 UTC] pajoye@php.net
Use the FILTER_FORCE_ARRAY array. It allows array as input and always returns an array (skipping a pointless if (is_array($a)) test).

Or use FILTER_REQUIRE_ARRAY if you expect an array.

No bug > bogus.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC