krike Posted April 8, 2010 Share Posted April 8, 2010 In codeIgniter I have the following returned array: Array ( [0] => stdClass Object ( [id] => 1 [name] => 01. Underworld [userid] => 1 [order] => 1 ) [1] => stdClass Object ( [id] => 2 [name] => 02. Pain in the ass [userid] => 1 [order] => 2 ) ) I need the to save the id into a variable and send it as parameter for the new functions, but I don't know how to do this. Any help would be appreciated, this is the controller function: /*###################################################*/ function members_area() /*###################################################*/ { global $site_title; $this->load->model('membership_model'); if($this->membership_model->get_villages()): $villages = $this->membership_model->get_villages(); $data['rows'] = $villages; echo "<pre style='text-align:left;'>"; print_r($villages); echo "</pre>"; $id = 1;//this should be dynamic, but how? if($this->membership_model->get_tasks($id)): $data['tasks'] = $this->membership_model->get_tasks($id); endif; endif; $data['title'] = $site_title." | Your account"; $data['main_content'] = 'account'; $this->load->view('template', $data); }//end of function members_area Link to comment https://forums.phpfreaks.com/topic/197995-sub-array-value/ Share on other sites More sharing options...
monkeytooth Posted April 8, 2010 Share Posted April 8, 2010 look into foreach. $a = array(); $a[0][0] = "a"; $a[0][1] = "b"; $a[1][0] = "y"; $a[1][1] = "z";foreach ($a as $v1) { foreach ($v1 as $v2) { echo "$v2\n"; } } ^ little sniplet from php.net on foreach Link to comment https://forums.phpfreaks.com/topic/197995-sub-array-value/#findComment-1038945 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.