db->query($sql)->result_array(); foreach($providers as &$provider) { $sql = ' SELECT id_services FROM ea_services_providers WHERE id_users = ' . $this->db->escape($provider['id']); $providerServices = $this->db->query($sql)->result_array(); if (!isset($provider['services'])) { $provider['services'] = array(); } foreach($providerServices as $providerService) { $provider['services'][] = $providerService['id_services']; } } return $providers; } } ?>