CodeIgniter Forums
$this->input->post() not working for me - 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() not working for me (/showthread.php?tid=14704)



$this->input->post() not working for me - El Forum - 01-12-2009

[eluser]RS71[/eluser]
Hello,

I am currently trying to use $this->input->post() in my controller but it doesn't seem to be working.

I currently have it so a select has a name of grau[] (an array).

In the controller, I try to do something like:

Code:
$data['grau_field'] = 'grau[]';

$data['education_count'] = count( $this->input->post($data['grau_field']) );

It doesn't seem to be showing the correct count, even though I can see that the POST values are there. (via the Profiler)

Could anybody please assist me?

Thanks in advance.


$this->input->post() not working for me - El Forum - 01-12-2009

[eluser]elvix[/eluser]
try removing the brackets from your grau_field value.


$this->input->post() not working for me - El Forum - 01-12-2009

[eluser]RS71[/eluser]
That would make the input not an array would it not? I need it as an array.


$this->input->post() not working for me - El Forum - 01-12-2009

[eluser]RS71[/eluser]
Ah I got it thanks.

I removed the brackets from the post() like you said.


$this->input->post() not working for me - El Forum - 01-12-2009

[eluser]RS71[/eluser]
Another question:

How can I retrieve a certain value from an array?

Code:
Array
(
    [0] => ABC
    [1] => XYZ
)

How can I get the value for the second key?


$this->input->post() not working for me - El Forum - 01-12-2009

[eluser]Colin Williams[/eluser]
$array[1]