Shashank Gaurav Shashank Gaurav - 1 year ago 86
PHP Question

How to access object properties in php

My php code is below:

$data['details'] = $this->category_model->edit_category($id);
print "<pre>"; print_r($data); die;

When I am using print my output is:

[details] => stdClass Object
[id] => 31
[c_parent_id] => 3
[c_name] => Sandles


I want to access "c_name". How to access it?

Answer Source

This will print the value:

echo $data['details']->c_name;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download