0

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

object(stdClass)#7 (1) { [0]=> object(stdClass)#6 (2) { ["contactId"]=> string(2) "nV" ["email"]=> string(31) "[email protected]" } } 

how do i access the email part with PHP

3
  • 2
    Possible duplicate of How to print nested stdclass object array Commented Dec 1, 2016 at 5:12
  • I've tried variations of that $result4->{0} $result4->0 they don't work. Commented Dec 1, 2016 at 5:15
  • try $result4->[0]->email Commented Dec 1, 2016 at 5:21

1 Answer 1

2

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.

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

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.