1

can someone tell me how to get the e.g Firstname or Email value from this array?

Array
(
    [0] => User Object
        (
            [UserId:UserData:private] => 1
            [Enabled:UserData:private] => 1
            [RbComms:UserData:private] => 0
            [UserLevel:UserData:private] => Admin
            [Password:UserData:private] => 098f6bcd4621d373cade4e832627b4f6
            [IP:UserData:private] => 
            [BalanceReminder:UserData:private] => 0
            [ThirdpartyComms:UserData:private] => 0
            [CreationTime:UserData:private] => 2011-07-04 14:04:00
            [Browser:UserData:private] => 
            [Email:UserData:private] => [email protected]
            [Username:UserData:private] => admin
            [Mobile:UserData:private] => 5465651651
            [Latitude:UserData:private] => 
            [Firstname:UserData:private] => Admin
            [Lastname:UserData:private] => Henderson
            [Longitude:UserData:private] => 
            [Balance:UserData:private] => 0.00
        )

4 Answers 4

2

They are private members, so you need to use the User class' methods to get at them.

These are usually something like $myuser->getEmail(), but it depends on how it is defined in the class. Read its source code to find out.

Sign up to request clarification or add additional context in comments.

3 Comments

did you meant $myuser->getEmail(); as it is a method call not accessing a property directly.
Or make them accessible via Reflection.
@Paul, good catch. @hakre, surely the best approach would be to access the method in the way intended by the class, yes?
0

You should do:

$the_array[0]->Firstname 

or

$the_array[0]->Email

Hope this helps. Cheers

Comments

0
echo $array[0]->Firstname; 

or, more properly:

foreach ($array as $user)
{
    echo $user->Firstname;
}

Edit: Brad's answer is also correct, as these are private variables, the class should also provide "get" methods, such as

$array[0]->GetFirstname(); 

Comments

0

Interesting syntax. I'd try this:

 var_dump( $array[0]->Email ); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.