How to get all post data in Codeigniter

Before you have to do this long boring way to get all the post datas using Codeigniter.
$post = array();
foreach ( $_POST as $key => $value )
{
    $post[$key] = $this->input->post($key);
}
var_dump($post); 
Since CI 2.1.0, you can now do the following easy way to get all post data from the form.
$data = $this->input->post(NULL, TRUE); // returns all POST items with XSS filter
$data = $this->input->post(); // returns all POST items without XSS filter 
This can be handy if you have dynamically built form with a lot of fields and can't define each field's name. With this method you can get all post data from the form.

Comments

Post a Comment

Popular Posts