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] => [EMAIL PROTECTED]
    [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



On 4/9/04 4:06 PM, "Richard Harb" <[EMAIL PROTECTED]> wrote:

> do a print_r() for the structure. --> print_r($_SESSION["OBJ_user"]);
> and look at the page source.
> 
> at each level ...
> if is says array refer to it with ['property']
> if obj (stdClass or otherwise) use -> that arrow thingy
> 
> I am not sure what the arrows in you desc mean, whether it's key/value
> pair of the array or hints to it being an object's property.
> 
> hth
> 
> Richard
> 
> Friday, April 9, 2004, 9:43:36 PM, you wrote:
> 
>> Hi, being somewhat of a noob, I hope I'm using the right language to phrase
>> this question...
> 
>> In a project I am working with, I have a multi-dimensional array in session
>> when a user logs in. Visually, it looks something like this...
> 
>> OBJ_user
>>     username => value
>>     isAdmin => value
>>     modSettings =>  contacts => array
>>                     news => array
>>                     listings => firstname => value
>>                                 lastname => value
>>                                 active => value
>>                                 phone => value
>>                     gallery => array
>>                     anothermod => array
>>     userID => value
>>     js => value
> 
> 
>> I'm trying to check the value of active for an if() statement and can't seem
>> to figure out the correct syntax to get it to work. I've tried
> 
>> if($_SESSION["OBJ_user"]->modSettings["listings"]->active == "1") {
>>     then do something;
>> } else {
>>     then do something else;
>> }
> 
>> if($_SESSION["OBJ_user"]["modSettings"]["listings"]["active"]) {
>>     then do something;
>> } else {
>>     then do something else;
>> }
> 
>> if($_SESSION["OBJ_user"]["modSettings"]["listings"]["active"] == "1") {
>>     then do something;
>> } else {
>>     then do something else;
>> }
> 
>> and none of them work even though I know the session value is there.
> 
>> Any advice as to what I'm doing wrong?
> 
>> Thanks,
>> verdon
> 
> 
> 
> 
> 
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to