Alessandro Alessandro - 1 year ago 76
PHP Question

Accessing array with nested objects

I have an api wrapper i am using that returns something like this

object(stdClass)#7 (1) {
object(stdClass)#6 (2) {
string(2) "nV"
string(31) ""

how do i access the email part with PHP

Answer Source

Cast your API returned data to an array.

For example you are saving API returned data in $result variable. Cast it to an array.

$arrayResult = (array) $result;

echo $arrayResult[0]->email;

Try this.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download