Welcome Guest, Not a member yet? Register   Sign In
How to sanitize request->getPost in bulk/array
#1

Hi,

So far based on documentation, it stated we can sanitize multiple field in an array but only for 1 same filter.

PHP Code:
$request->getPost(['field1''field2'], FILTER_SANITIZE_STRING); 

However, is there any way we can also sanitize multiple field for multiple filter?
example like below.

PHP Code:
$request->getPost([
  [[
'field1''field2'], FILTER_SANITIZE_STRING)],
  [[
'field3''field4'], FILTER_SANITIZE_EMAIL)],
  [
'field5'FILTER_SANITIZE_NUMBER_INT)]
]; 

or, i really need to sanitize 1 by 1 based on the FILTER?

it just that, if my function require a lot of POST, that would be disaster to sanitize line by line.
Reply
#2

PHP.NET has a filter_input_arry method that you may be able to use.

PHP.NET - filter_input_array

See the first example of it's use.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB