I have the following PHP object but I’m struggling to get the array item out of the object.
exampleBatch Object (
[file_path:protected] =>
[title:protected] =>
[description:protected] =>
[link:protected] =>
[items:protected] => Array ( )
[raw:protected] => data/example
[feed_nid:protected] =>
Array (
[0] => Array ( [path] => data/example/example/ [filename] => file.csv )
[1] => Array ( [path] => data/example/example/ [filename] => file.csv )
[2] => Array ( [path] => dexampleata/example// [filename] => file.csv ) )
[current_item:protected] =>
[created] => 0
[updated] => 0
[total:protected] => Array ( )
[progress:protected] => Array ( [fetching] => 1 [parsing] => 1 [processing] => 1 ) )
I need to access array containing the three keys and it’s data for some post processing.
Whats the best way to go about grabbing the array?
If you can edit the class, either change the property you care for to public or write a getter for it:
Otherwise if you can’t edit the class itself, you can extend it since the properties you want are protected which means a child class can access them:
Then you’ll need to create an instance of YourClass instead of ThatClass and get the items array from it.
Similarly for any other protected properties you want.