I have php array like this which generated from php controller.
Array
(
[data001] => Array
(
[0] => stdClass Object
(
[page_id] => 204725966262837
[type] => WEBSITE01
)
[1] => stdClass Object
(
[page_id] => 163703342377960
[type] => COMMUNITY02
)
)
[data001] => Array
(
[0] => stdClass Object
(
[page_id] => 204725966000037
[type] => WEBSITE02
)
[1] => stdClass Object
(
[page_id] => 163703342377960
[type] => COMMUNITY02
)
)
)
I want to echo these two array within same foreach loop.
I Tried like this but it didn't worked.
foreach ($results as $result) {
echo $result->type;
echo "<br>";
}
But I didn't want to use foreach ($results['data001'] as $result) Because I Have to write two foreach loops.
foreachstatements? It's the legit way to read 2D+ arrays.foreach ($results['data001'] as $key=>$result) { ... $results['data001'][$key->type] ... }$job_category_data = array( 'common' => $this->auth_model->get_random_job_categories("JobCategoryId"), 'location1' => $this->auth_model->get_random_job_categories("Title") ); $data['job_categories'] = $job_category_data; $this->load->view('index', $data);