CodeIgniter Forums
Array - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: Array (/thread-8721.html)

Array - El Forum - 05-28-2008

How can I turn post variables into an array?

$arg['fname'] = ?
$arg['lname'] = ?
$arg['email'] = ?

am i doing this right?

Array - El Forum - 05-28-2008

If you aren't using xss_clean() you can just use the $_POST array.

If you are using xss_clean() you can set
$config['global_xss_filtering'] = TRUE;
In application/config/config.php and it will run xss_clean() on everything in the $_POST array, or you can do a one off:
$_POST['email'] = $this->input->xss_clean($_POST['email')

Array - El Forum - 05-28-2008

would i be able to do something like this in CI..?

$fname = $this->input->post(’fname’);
$arg[’fname’] = $fname;
$lname = $this->input->post(’lname’);
$arg[’lname’] = $lname;
$email = $this->input->post(’email’);
$arg[’email’] = $email;

and then do

foreach($arg as $key=>$value)...

It seems the $arg[''] = $whatever;
doesnt work at all... why?

Array - El Forum - 05-28-2008

[eluser]Jamie Rumbelow[/eluser]
If you want to loop through, just use this:

foreach ($_POST as $key => $value) {

$arg[$key] = $value;


Remember - the $_POST array functions just as a regular array does.