Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Filter / sanitize array data from $_POST

Hello,

To filter a something from $_POST _in phalcon , we use :

         'unit' => $this->request->getPost('unit', 'int').

However how to do deal if I have "unit" variable from $_POST is array ie.

   unit = aray (
            0 => 5,
            1 => 9,
            2 => 18,
            3 => 2
            );


85.2k
Accepted
answer
edited Jul '18

It works for array values also. Just tested myself.

Without sanitize $this->request->getPost('asd')

Array
(
    [0] => asd___1
    [1] => asd___5
    [2] => asd___8
)

With sanitize $this->request->getPost('asd', 'int')

Array
(
    [0] => 1
    [1] => 5
    [2] => 8
)


2.9k

Thanks for confirmation, much appreciated.