I am getting my query output in the model and sending to controller If I check the data in the controller like print_r($result);
I am getting the output from my Model and My output is
stdClass Object
(
    [membership_id] => 11
    [member_id] => 10
    [customer_id] =>21
    [membership_approve] => 1
    [membership_status] => 1
    [profile_pic] => 
    [first_name] => Juvin
    [middle_name] => kumar
    [last_name] => choudhary
    [email] => juvin@gmail.com
    [dob] => 2018-07-01
    [phone] => 01236541254
    [is_Approved] => 1
)
Model code is
if ($result) {
  foreach($result as $result_set ){
     if($result_set->membership_status == 1)
      {
      $result2=$this->db->select('*')
            ->from('membership_details')
            ->join('members','members.member_id = membership_details.member_id')
            ->group_start()
                ->where('members.is_Approved',1)
                ->where('membership_details.membership_status', 1)
                ->where('membership_details.member_id',$result_set->member_id)
              ->group_end()
             ->get()
            ->row();
          return $result2;
      }
      else 
      {
        return 0;
      }
    }
  }
  else{echo "Not working";}
Now I am on the controller. I am passing the output in the foreach but when I check $row->phone then it's showing me
Message: Trying to get property of non-object
`$result=$this->Search_model->check_membership($customer_name,$customer_mobile); 
    $arr_result2 = array();
    if (count($result) > 0)
         {
            print_r($result);// It's displaying the same output which I aaded in the question.
            foreach($result as $row){
                print_r($row->customer_id);// not getting customer id
                $arr_result2[] = array(
                    "profile_pic" => $row->profile_pic,
                    "name" => $row->first_name.' ' .$row->last_name,
                    "phone" => $row->phone
                );
            }
            }
         else{echo "No data availble";}
         //print_r($arr_result2);
        echo json_encode($arr_result2);
 
    