I am using Codeigniter 3 and getting data from an API. The API returns the below after I pass the origin json data through, $myArray = json_decode($theBody, true);
array(2) {
["status"]=>
string(7) "failure"
["message"]=>
array(2) {
["entry_name"]=>
string(61) "The entry_name field must be at least 8 characters in length."
["entry_body"]=>
string(61) "The entry_body field must be at least 8 characters in length."
}
}
I now want to pass that error message via flashdata to my view which I do as follows:
// VIEW FILENAME: new.php
$this->session->set_flashdata('message', $myArray);
In my view, when I run this:
echo "<pre>";
echo var_dump($this->session->flashdata('message'));
echo "</pre>";
I get the expected output (same as above):
array(2) {
["status"]=>
string(7) "failure"
["message"]=>
array(2) {
["entry_name"]=>
string(61) "The entry_name field must be at least 8 characters in length."
["entry_body"]=>
string(61) "The entry_body field must be at least 8 characters in length."
}
}
However, how can I iterate through the array?
How can I refer to the contents of ["status"] and ["message"]
Any pointers appreciated.