我的PHP代码:
$stuff = array($this->complaint_model->get_reply($id)->result());
print_r($stuff);
结果:
Array (
[0] => Array (
[0] => stdClass Object (
[id_customer] => 21
[id_complaint] => 2
[id] => 4
[nama_customer] => Muhammad Bima Zehansyah
[from] => Admin
[balasan] => coba update
)
)
)
我的问题是,如何获得价值[nama_customer]? thx之前的人
答案 0 :(得分:1)
试试这个
$stuff = array($this->complaint_model->get_reply($id)->result());
echo $stuffVal = $stuff[0][0]->nama_customer;
答案 1 :(得分:0)
获得这样的价值
$stuff[0][0]->nama_customer
这里你有多维数组对象这就是你需要首先遍历两个数组$stuff[0][0]
然后像$stuff[0][0]->nama_customer
答案 2 :(得分:0)
实际上你不需要将结果放到额外的array
中,检查结果是否为空是明智的。
因此,您只需从结果中获取第一项(这是一个对象)并调用参数nama_customer
$stuff = $this->complaint_model->get_reply($id)->result();
if (!empty($stuff[0]))
echo $stuff[0]->nama_customer;