I am using CodeIgniter. I am getting the response from model and display on the controller.
Model
//some code here
return array('secondary_data'=> $result,'primary_data' =>$result2);// sending to controller
// some code here
Controller
$result=$this->Search_model->get_search_name($cust_name);//calling model
$data['secondary_data'] = $result['secondary_data'];
$data['primary_data'] = $result['primary_data'];
print_r($data['secondary_data']);
print_r($data['primary_data']);
output
Array
(
[0] => stdClass Object
(
[member_id] =>
[customer_id] =>
[first_name] => qwer
[last_name] => poiu
[email] =>
[member_type] => 2
)
)
Array
(
[0] => stdClass Object
(
[member_id] => 1
[customer_id] => 0011
[first_name] => asdasd
[last_name] => asdasda
[email] => [email protected]
[member_type] => 1
)
)
but sometimes I am getting empty array of print_r($data['primary_data']) because of no data. Yes, it's possible.;
but in below if condition I am checking the data count count($data) > 0 and if found empty then calling the else part.
I don't want to call else part if only one array is emply. if both array is empty then it should call else part
if (count($data) > 0)
{
$data['title'] = "Search";
$data['heading'] = "Search";
$data['content'] = $this->load->view('search',$data,true);
$this->load->view('dashboard/dashboard',$data);
}
else{
echo "NO data available";
}
Any idea how to do this? Thanks
condition for both arrayor Useloopand check