Re: Finding value in multi-dimensional array
| From: | Richard Harb | Date: | Fri, 09 Apr 2004 20:49:44 +0000 |
| Subject: | Re: Finding value in multi-dimensional array | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-183032@lists.php.net to get a copy of this message | ||
No problem ..
Let's see:
if($_SESSION['OBJ_user']->modSettings['listings']['active'] ==
'1') {
That should be it ...
Sidenote: use single quotes whenever the string needn't be evaluated
(i.e. is a variable itself) you save a couple cycles every time.
hth
Richard
Friday, April 9, 2004, 10:32:25 PM, you wrote:
> Sorry, my example was poor :) Thanks for the print_r tip. When added to the
> bottom of the page,
> print_r($_SESSION["OBJ_user"]);
> Prints...
> phpws_user Object
> (
> [user_id] => 5
> [username] => agent
> [password] => 77abcd5cb2ef4a366c2749ea9931c79e
> [email] => agent@email.com
> [admin_switch] => 1
> [deity] =>
> [groups] => Array
> (
> )
> [modSettings] => Array
> (
> [listings] => Array
> (
> [active] => 1
> [first_name] => Agent
> [last_name] => Guy
> )
> )
> [permissions] => Array
> (
> [MOD_debug] => 1
> )
> [groupPermissions] =>
> [groupModSettings] =>
> [error] => Array
> (
> )
> [temp_var] =>
> [last_on] => 1081527610
> [js_on] => 1
> [user_settings] =>
> [group_id] =>
> [group_name] =>
> [description] =>
> [members] =>
> )
> So, should my reference be...
> if($_SESSION["OBJ_user"]["modSettings"]["listings"]->active ==
> "1")
> That didn't seem to work, but if it should, perhaps I need to look somewhere
> else?
> Thanks,
> Verdon
<snipped>