CodeIgniter Forums
Are $this->input->post() and set_value interchangeable? - 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: Are $this->input->post() and set_value interchangeable? (/showthread.php?tid=14749)



Are $this->input->post() and set_value interchangeable? - El Forum - 01-13-2009

[eluser]RS71[/eluser]
Hey

Are $this->input->post() and set_value() interchangeable? I can't seem to use $this->input->post() when I want to retrieve an array value (ex: field[0] ). It returns nothing for some reason, even though the array has things in it.

Thanks


Are $this->input->post() and set_value interchangeable? - El Forum - 01-14-2009

[eluser]RaF007[/eluser]
I might be wrong but I think you can only grab the whole array at once using $this->input->post(). Let's say your POST contains an array FIELD containing several values (FIELD[0], FIELD[1], ...), you would have to do the following:

Code:
// WILL NOT WORK
echo $this->input->post('FIELD[0]');

// THIS SHOULD WORK
$myarray = $this->input->post('FIELD');
echo $myarray[0];
echo $myarray[1];

If I'm incorrect, I'm interested into seeing a solution for this as well.


Are $this->input->post() and set_value interchangeable? - El Forum - 01-14-2009

[eluser]xwero[/eluser]
With the previous validation library the validation->fieldname and input->post('fieldname') were interchangeable but the new library doesn't alters the post values anymore.