0

I have the following object...

Google\AdsApi\AdWords\v201809\o\MonthlySearchVolume Object
(
    [year:protected] => 2018
    [month:protected] => 10
    [count:protected] => 450000
)

And I cannot for the life of me figure out how to get the year, month, and count out and into a regular array.

Thanks in advance.

user2648990
  • 103
  • 1
  • 6

1 Answers1

0

You can check this response : How to get protected property of object in PHP by Álvaro-gonzález

Members declared protected can be accessed only within the class itself and by inherited and parent classes.

If you need to access the property from outside, pick one:

  • Don't declare it as protected, make it public instead
  • Write a couple of functions to get and set the value (getters and setters)

If you don't want to modify the original class (because it's a third-party library you don't want to mess) create a custom class that extends the original one:

class MonthlySearchVolume {}

... and add your getter/setter there.

Fizik26
  • 753
  • 2
  • 10
  • 25