CodeIgniter Forums
$this->input->post question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: $this->input->post question (/showthread.php?tid=4143)



$this->input->post question - El Forum - 11-08-2007

[eluser]europe72[/eluser]
foreach ($this->input->post() as $key => $value) ... doable?


$this->input->post question - El Forum - 11-08-2007

[eluser]xwero[/eluser]
No because the post method only checks if the key exists, cleans xss data if you want it and returns the value associated with that key.
You could extend the input class
Code:
function postarray( $xss_clean = FALSE)
    {        
        if ( ! isset($_POST) or count($_POST) == 0)
        {
            return FALSE;
        }

        if ($xss_clean === TRUE)
        {
                $keys = array_keys($_POST);
                    foreach($keys as $index)
                    {
                        if (is_array($_POST[$index]))
            {
                foreach($_POST[$index] as $key => $val)
                {                    
                    $_POST[$index][$key] = $this->xss_clean($val);
                }
            }
            else
            {
                $_POST[$index] = $this->xss_clean($_POST[$index]);
            }
                    }
        }

        return $_POST;
    }