dongshijiao6890 2016-07-02 02:53 采纳率: 0%
浏览 39
已采纳

如何获取codeigniter中where子句的数组中的所有数据

this is my vardump which return array :

array(5) {
  [0]=>
  string(1) "1"
  [1]=>
  string(1) "5"
  [2]=>
  string(1) "9"
  [3]=>
  string(2) "13"
  [4]=>
  string(2) "17"
}

that array is $cuisines_category

i need to get that 1,5,... for where clause, i have tried this to get all the value :

foreach($cuisines_category as $key => $value){
        $cuisines_category_all = $this->Control_panel_m->m_get_cuisines_name_by_id($value);
    }

but its only returing 1 value. I need to return all of them

guys can you help me how to get it?

thank you (:

p.s the long of array can be change

  • 写回答

1条回答 默认 最新

  • dongqiaogouk86049 2016-07-02 03:00
    关注

    You overwrite the same variable $cuisines_category_all in each iteration of the loop so it will only contain the value from last iteration

    Perhaps you want it to be an array in which case do

    foreach($cuisines_category as $key => $value){          
          $cuisines_category_all[] = $this->Control_panel_m->m_get_cuisines_name_by_id($value);
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 需要写计算过程,不要写代码,求解答,数据都在图上
  • ¥15 向数据表用newid方式插入GUID问题
  • ¥15 multisim电路设计
  • ¥20 用keil,写代码解决两个问题,用库函数
  • ¥50 ID中开关量采样信号通道、以及程序流程的设计
  • ¥15 U-Mamba/nnunetv2固定随机数种子
  • ¥15 C++行情软件的tick数据如何高效的合成K线
  • ¥15 vba使用jmail发送邮件正文里面怎么加图片
  • ¥15 vb6.0如何向数据库中添加自动生成的字段数据。
  • ¥20 在easyX库下编写C语言扑克游戏跑的快,能实现简单的人机对战