[eluser]Unknown[/eluser]
Hi Guys,
One of the problems I encounter is retrieving a value of an array within a session. I will give you an example:
<?php
/* SET SOME DATA */
$arr_person = array('firstname' => 'Danny', 'lastname' => Klaassen', 'initials' => 'D');
$arr_login = array('username' => 'dklaassen', 'rank' => 1);
$arr_data = array('person' => $arr_person, 'login' => $arr_login);
$this->session->set_userdata($arr_data);
?>
What if I want to check the users rank. Now I use the following code:
<?php
/* Check user rank bitwise */
$arr_user = $this->session->userdata('login');
if ($arr_user['rank'] & 1)
{
...
}
else
{
...
}
?>
I prefer to access the rank immediately, without the intervention of $arr_user. Is there any way to achieve that?