I have an array that saves the values from a counter and I want to send that array to my controller to open another view.
for example I'm in main_view.php in my views folder... within my main_view.php I have a counter and a array that increase with data when something happens.
$counter = 0;
$arr = array();
foreach($value->result as $val){}
if($val->somethinghappenedtrue){
$counter++;
$arr[] = array('data' => $thethingthathappened);
}
}
$array_encoded = json_encode($arr);
then in my anchor I have:
anchor('controller/method/'.$array_encoded ,'Counter:: '.$counter, array('title'=>'ARRAY SENT'))
and in my view that I want to open with the anchor i have
controller{
method($array_encoded){
$array_decoded = json_decode($array_encoded);
echo '<pre>';
print_r($array_decoded);
echo '</pre>';
$this->load->view('other_view');
}
}
but it does not work it gives me:
Severity: NoticeMessage: Undefined variable: $array_encoded
As can be seen here http://www.codeigniter.com/userguide2/libraries/uri.html I think You will have to use $this->uri->segment(3) to get the value of variable $array_encoded first and then you may now decode it and assign it $array_decoded...but then sending an array via the anchor url is probably not the best of things to do.I dont know the specifics of your codes but have you tried posting it via an hidden input field?