christina
christina

Reputation: 661

PHP: Getting data out of an object

How can I get the user_nicename from this object?

BP_User Object
(
    [data] => stdClass Object
        (
            [ID] => 1
            [user_login] => NICENICE
            [user_pass] => $P$BwLHvV7zxcZZ/zW7MY0NXNSmANP.U5.
            [user_nicename] => NICENAME
            ...

And where can I find resources to learn this?

Upvotes: 8

Views: 36098

Answers (3)

VISHAL SONI
VISHAL SONI

Reputation: 1

I have this type data. And I have extracted data from the array like this. This type data

$original = new DateTime("2023-04-28T14:51:12-07:00");
$data = json_decode(json_encode($original));
$time = strtotime($data->date);
echo $time;

Upvotes: 0

Shiv Singh
Shiv Singh

Reputation: 7211

You can print by another way also

foreach($result->data as $newdata) //$result is variable that store raw data 
{
printf("name: %s, Pass: %s, nicename: %s <br/>", $newdata->user_login, $newdata->user_pass, $newdata->user_nicename);
}

Result will be

name:NICENICE , Pass:$P$BwLHvV7zxcZZ/zW7MY0NXNSmANP.U5., nicename:NICENAME

Upvotes: 3

Pekka
Pekka

Reputation: 449395

$variable->data->user_nicename

should work.

Upvotes: 27

Related Questions