gpt4 book ai didi

php - 无法在 codeigniter View 中显示逗号分隔值

转载 作者:行者123 更新时间:2023-11-29 01:53:05 25 4
gpt4 key购买 nike

我有这个数组我没有得到 area_tutor 因为它有带逗号的值

Array
(
[0] => stdClass Object
(
[tuitor_id] => 288
[mobile_tuitor] => 0123456789
[alt_mobile_tuitor] =>
[fullname_tuitor] =>
[gender_tuitor] => male
[city_tutor] => 2
[area_tutor] => 7,8,9
)

[1] => stdClass Object
(
[tuitor_id] => 287
[mobile_tuitor] => 2568798456
[alt_mobile_tuitor] =>
[fullname_tuitor] => sumit test new filed
[gender_tuitor] => male
[city_tutor] => 1
[area_tutor] => 3
)

[2] => stdClass Object
(
[tuitor_id] => 285
[mobile_tuitor] => 1452587658
[alt_mobile_tuitor] => 0789578469
[fullname_tuitor] => Sumit Nair
[gender_tuitor] => male
[city_tutor] => 1
[area_tutor] => 1,2,3,4
)

[3] => stdClass Object
(
[tuitor_id] => 273
[mobile_tuitor] => 0954652478
[alt_mobile_tuitor] =>
[fullname_tuitor] => vbvbbb
[gender_tuitor] => female
[city_tutor] => 1
[area_tutor] => 3
)

[4] => stdClass Object
(
[tuitor_id] => 225
[profile_title] =>
[mobile_tuitor] => 4557821212
[alt_mobile_tuitor] => 5445587112
[fullname_tuitor] => xyz
[gender_tuitor] => male
[city_tutor] => 4
[area_tutor] => 14
)

)

其中 area_tutor 有带逗号的值,我在从 foeach 循环中检索时没有得到我只得到 area_tutor 的第一个元素,这就是我用 foreach 循环循环的方式

$this->db->select('*')->from('tuitor');
$this->db->order_by("tuitor_id", "desc");
$this->db->join('city_tuitor', 'tuitor.city_tutor = city_tuitor.city_id', 'left');
$this->db->join('area_tuitor', 'tuitor.area_tutor = area_tuitor.area_id', 'left');

$query=$this->db->get();
return $result = $query->result();

现在看来我只是循环遍历 foreach 循环

如果我像这样打印我得到我得到上面的数组 打印_r($结果);

但是当我当时试图回显值时,我只得到 area_tutor 的第一个值

 <?php  foreach($result as $r) { ?>
echo $r->tuitor_id;
echo $r->mobile_tuitor;
echo $r->city_tutor;
echo $r->area_tutor;
<?php } ?>

请帮助我如何获取 area_tutor 的所有值

最佳答案

尝试打印值的简单方法..

<?php 
$result = $query->result_array();
foreach($result as $key=>$val)
{
echo $val['tuitor_id'];
echo $val['mobile_tuitor'];
echo $val['city_tutor'];
echo $val['area_tutor'];
}
?>

关于php - 无法在 codeigniter View 中显示逗号分隔值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36215194/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com