Reputation: 15
I have a result in this form
RowCollection {#780 ▼
#heading: array:7 [▶]
#title: "Sheet1"
#items: array:3 [▶]
}
i have to access heading ,but when i use foreach loop
foreach( $data as $key => $value){
echo $value;
}
it print out the items array value.So how to access to heading array ?
Upvotes: 0
Views: 1175
Reputation: 606
Based on my experience in laravel and its var_dumper, items signed with #
sign in dd()
output can be accessed as methods with follows pattern :
get{ItemStudlyCaseName}()
e.g getHeading()
getTitle()
getItems()
and items signed with +
sign can be accessed as properties.
Complete Description
In dd()
var_dumper output there is three sign :
#
protected property
+
public property
-
private property
protected properties can be accessed by getter methods with $object->get{PropertyStudlyCaseName}()
pattern.
public properties can be accessed directly. $object->propertyName
private properties is not accessible.
For example in Request object:
Request {#38 ▼
#json: null
#convertedFiles: null
#userResolver: Closure {#142 ▶}
#routeResolver: Closure {#143 ▶}
+attributes: ParameterBag {#40 ▶}
+request: ParameterBag {#46 ▶}
+query: ParameterBag {#46 ▶}
+server: ServerBag {#42 ▶}
+files: FileBag {#43 ▶}
+cookies: ParameterBag {#41 ▶}
+headers: HeaderBag {#44 ▶}
#content: null
#languages: null
#charsets: null
#encodings: null
#acceptableContentTypes: null
#pathInfo: "/"
#requestUri: "/"
#baseUrl: ""
#basePath: null
#method: "GET"
#format: null
#session: Store {#185 ▶}
#locale: null
#defaultLocale: "en"
-isHostValid: true
-isClientIpsValid: true
-isForwardedValid: true
basePath: ""
format: "html"
}
e.g
#
protected property : $request->getDefaultLocale()
+
public property : $request->attributes
-
private property : $request->isHostValid
=> returns null
Upvotes: 2