Model:
Grabs data from mySQL with the value: array['10','5','2'] and puts it in the session data
Controller:
Puts that session data into an array to pass to the view:
$fubar = array(
'ex1' => $this->session->userdata('ex1')
);
$this->load->view('view', $fubar);
View:
echo $ex1;
The view will spit out the array: array['10','5','2']
How do I parse that array to get the individual values (10, 5, or 2)?
For example, echo $ex1['1']; will spit out the first 1 characters: ar but I want it to return the value 5
I think perhaps I may not be storing the array properly in mySQL, but I'm not sure.
var_dump($fubar);before$this->load->view('view', $fubar);What does it display?eval(<php code here>). But it's not safe. It's very strange that you save array as string. it's better to use serialize($your_array) and unserialize($your_serialized_array) functions or json_encode() and json_decode() functions. In conclusion: 1. Save in session: serialize($your_array); 2. Extract from session: unserialize($this->session->userdata('ex1'))