Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/272.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从结果_数组()中提取其类型的值_Php_Arrays_Codeigniter - Fatal编程技术网

Php 从结果_数组()中提取其类型的值

Php 从结果_数组()中提取其类型的值,php,arrays,codeigniter,Php,Arrays,Codeigniter,我希望能够从result_array()查询中获取值,以便在另一个查询中使用 Array ( [0] => Array ( [taskID] => 10 ) [1] => Array ( [taskID] => 11 ) [2] => Array ( [taskID] => 12 ) ) 我希望能够循环遍历数组中的每个项,并返回要在where子句中使用的值(例如10、11、12) $task为数组,$t为数组中的项目 foreach($task

我希望能够从result_array()查询中获取值,以便在另一个查询中使用

Array ( 
  [0] => Array ( [taskID] => 10 )
  [1] => Array ( [taskID] => 11 )
  [2] => Array ( [taskID] => 12 )
)
我希望能够循环遍历数组中的每个项,并返回要在where子句中使用的值(例如10、11、12)

$task
为数组,
$t
为数组中的项目

foreach($task as $t){
    $this->db->select('roleID');
    $this->db->from('project_tasks');
    $this->db->where('taskID', $t); //ERROR line 287
}
错误:

错误号码:1054

“where子句”中的未知列“Array”

project\u roles
中选择
roleID
,其中
taskID
=
Array

文件名:models/Project_model.php

电话号码:287


您忘记了
$task
是一个数组:

foreach($task as $t){
    $this->db->select('roleID');
    $this->db->from('project_tasks');
    $this->db->where('taskID', $t['taskID']); 
}

这不应该是
$t[0]['taskID']
吗?这会给出所需的行为吗?@Xorifelse否
$t
$task
的一个元素。编辑之后,它会变得更有意义。我原以为数组是来自循环内部的转储。
foreach($task as $t){
    $this->db->select('roleID');
    $this->db->from('project_tasks');
    $this->db->where('taskID', $t['taskID']);
}