user3485932
user3485932

Reputation: 5

Array of stdClass objects

I need to pull out the [name] information only from this array that includes php stdClass Objects. How do I do this please?

Array ( [VigdiH] => stdClass Object ( [ip] => 555.50.175.142 [name] => Test Name [origin] => www [cycle_day] => 3 [email] => [email protected] [campaign] => 5555 [created_on] => 2014-03-28 14:22:58 [changed_on] => ))

Upvotes: 1

Views: 1033

Answers (2)

Jeff Lambert
Jeff Lambert

Reputation: 24661

If your array is named $arr you could do:

foreach($arr as $object) {
    echo $object->name . "\n";
}

Upvotes: 3

Halcyon
Halcyon

Reputation: 57709

You can get properties from an object using ->

$data = array(/**/);
$data["VigdiH"]->name; // name

Upvotes: 2

Related Questions