[eluser]jplanet[/eluser]
I have a VERY bizarre probem. When I use code to loop through form fields using the $_POST array in a foreach block, I get strange errors in other code later on the page. I am chalking this up to a bug in PHP5.
From what I can find, Codeigniter's input class only provides acces sto individual post variables using $this->input->post('fieldname'). Is there a way I can access the array of post variables using a Codeigniter function?
For those who are curious, this is the code that breaks my application:
Code:
foreach($_POST as $key => $data) {
if(strstr($key,"wrap_")){
$cart_id = stristr($key,"_");
$cart_id = str_replace("_","",$cart_id);
$this->cart_model->addWrap($cart_id);
}
}
Once I insert this code, I get this error:
Code:
A PHP Error was encountered
Severity: Notice
Message: Array to string conversion
Filename: controllers/checkout.php
Line Number: 290
Line 290 refers to this very simple line of code, which does not generate an error when I delete the foreach statement above:
Code:
$data['cart'] = $this->cart_model->getCart($this->session->userdata('session_id'));
Even if I replace the body of the foreach block with a simple echo statement, it produces the same error. As long as I loop through POST variables using foreach, I get the error.