如何从数组中获取单个值?

时间:2018-09-12 02:42:04

标签: php arrays codeigniter-3

我正在使用CodeIgnator。我要从模型中返回$result = $query->result();

控制器

$get_cust_previous_info=$this->Customer_model->get_cust_previous_info($cust_mob);

echo"<pre>";
print_r($get_cust_previous_info);
echo "</pre>";

我正在获取数组值

Array
(
    [0] => stdClass Object
        (
            [cust_id] => 8
            [c_b_id] => 8
        )

)

1)现在,我必须分配cust_id和c_b_id值 像

$cust=$get_cust_previous_info['cust_id'];
$c_b=$get_cust_previous_info['c_b_id'];

2)有时我还会返回模型中的行$result = $query->row();

获取数组

stdClass Object
(
    [cust_id] => 8
    [c_b_id] => 8
)

$cust=$get_cust_previous_info['cust_id'];
$c_b=$get_cust_previous_info['c_b_id'];

如何获取cust_id和c_b_id值?因为我必须将单个值分配给变量。

您能帮我吗?

0 个答案:

没有答案