$arr = NSZone::find_all(array('per_page'=>20, 'page'=>1));
return result is
[0] => NSZone Object
(
[xml_skip_attribs:protected] => Array
(
[0] => id
)
[vals:protected] => Array
(
[total_count] => 3
)
)
he is accessing
arr[0]['vals:protected']['total_count'] in this way arr[0]->total_count()
That’s mean total_count() is a function whereas according to array structure its look like array index.
Please Explain me this code, how it work? What is [vals:protected] and can it be public, private etc as well, Any more explanation you know please?
That is not an array but a
print_r($arr)of the NSZone Object, if your not in the class meaning your accessing it in the same scope as your using print_r($arr) and the property’s are set to private/protected then you cannot access the values within the object if your outside of it, you would need to add a getter of sort, or change it to public.If the class using a __get() magic method you maybe could access it like:
$arr->total_count;or you could add a method to get it, and access it like:
$arr->getCount();But without seeing the class, its hard to tell, so I could be completely out.