Welcome Guest, Not a member yet? Register   Sign In

How can I turn post variables into an array?

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

am i doing this right?

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')

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?

[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.

Theme © iAndrew 2016 - Forum software by © MyBB