I am trying to create a php object that has the following layer.
$obj->property->name;
$obj->property->title;
$obj->property->id;
$obj->property->height;
It give me 'Trying to get property of non-object' error
My object
$obj = [
'property' => [
'name' => 'Rick',
'title' => 'manager',
'id' => '123',
'height' => '5.6'
]
];
$obj = = (object)$obj;
I am not sure the correct syntax to produce $obj->property->name;Can anyone help me out? My brain is fired....Thanks!
$objis declared as an array, you could just cast(object)on declaration$obj->property['name'];