I have this select
$this->db->select('modulo_regra.regra_descricao');
$this->db->from('modulo_regra');
$this->db->where('modulo_regra.modulo_regra_id', id);
$query = $this->db->get();
that return to me 2 elements in
return $query->result_array();
Then I put the return in a Array
$permissoes =array('areas' => $this->Regra_model->user_has($regra['regra_id']));
then I the $permissoes to the session
$this->session->set_userdata($permissoes);
So the real problem comes here. when I'm loading the value from session
$permissoes = array('areas');
$permissoes = $this->session->userdata('areas');
this is its content:
array(2) ([0] => array(1) ([regra_descricao] => (string) clientes_cadastrar)
[1] => array(1) ([regra_descricao] => (string) clientes_visualizar))
So i can't validate it with the in_array(), or other way...I would like to know if there is how if there is away to compare the value in this array with one another variable
like
if(in_array('clientes_cadastrar',$permissoes)){}
I'm new on it... so sorry for the way i ask.
don't put entire array in return i.e
foreach ($query->result() as $row)
{
$return[] = $row->regra_descricao;
}
return $return;
THEN
you can easily find using:
if(in_array('clientes_cadastrar',$permissoes[**'areas'**])){}
hope this helps
U can use the same scope.
$this->db->select('modulo_regra.regra_descricao');
$this->db->from('modulo_regra');
$this->db->where('modulo_regra.modulo_regra_id', id);
$query = $this->db->get();
foreach ($query->result() as $row)
{
$permissoes = array['areas'];
}
$this->session->set_userdata($permissoes);